Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is Color equality right?  (Read 3416 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Is Color equality right?
« on: May 25, 2014, 04:35:52 am »
This line looks very weird to me even though I don't really know C#:
https://github.com/SFML/SFML.Net/blob/master/src/Graphics/Color.cs#L81
Isn't it always true if obj is a color?
shouldn't it instead read one of these or similar?
return (obj is Color) && Equals(obj as Color);
return (obj is Color) && Equals((Color)obj);
« Last Edit: May 25, 2014, 04:40:47 am by FRex »
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Is Color equality right?
« Reply #1 on: May 25, 2014, 11:13:38 am »
You're right. Another possibility:

return (obj is Color) && obj.Equals(this);
Laurent Gomila - SFML developer

Deathbeam

  • Jr. Member
  • **
  • Posts: 82
  • VB6, VB.NET, C#, HTML, PHP, CSS, JavaScript nerd.
    • View Profile
    • My portfolio
    • Email
Re: Is Color equality right?
« Reply #2 on: May 25, 2014, 12:15:25 pm »
Oh yea, sorry, my mistake, I forgot to put obj. before Equals(this), I will correct it.
« Last Edit: May 25, 2014, 12:50:24 pm by Deathbeam »
Spooker Framework - Open source gaming library
My portfolio
Indie Armory - Small community of a game developers. Everyone is welcome. Bring your friends, family, pets...

 

anything