Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we use == rather than ===
#7
(10-11-2010, 06:43 AM)phire nuk3r Wrote: Because it would have to be exact 100% For example it would even not return true if the case was different etc.

Nor would the equals (==) operator. "Hey" and "hey" are not equal; 4 and "4" are equal but not identical. The equals operator does not eliminate case sensitivity. In order to do that you'd need to use a function such as strcasecmp () or strtolower ()/strtoupper (). The difference being that strcmp ()/strcasecmp () are binary safe and the equals/identical operators are not.

And Orgy, no, (1 === "1") would return false. They are equal (1 == "1") but they are not identical due to the difference in data type. The LHV is an integer and the RHV is a string literal.
Ho, ho, ho! Well, if it isn't fat stinking billy goat Billy Boy in poison!
How art thou, thou globby bottle of cheap, stinking chip oil?
Come and get one in the yarbles, if ya have any yarbles, you eunuch jelly thou!
Reply


Messages In This Thread
Why do we use == rather than === - by Orgy - 10-11-2010, 06:39 AM
RE: Why do we use == rather than === - by Disease - 10-11-2010, 06:42 AM
RE: Why do we use == rather than === - by Disease - 10-11-2010, 09:12 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 09:27 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 06:45 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 06:57 AM
RE: Why do we use == rather than === - by Chimi - 12-06-2010, 01:29 AM
RE: Why do we use == rather than === - by Orgy - 12-09-2010, 06:23 AM

Forum Jump:


Users browsing this thread: 4 Guest(s)