Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Equals sign
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Several equals signs=== In some programming languages, <code>==</code> and <code>===</code> are used to check equality, so <code>1844 == 1844</code> will return true. In [[PHP]], the [[===|triple equals sign]], {{code|1====}}, denotes value and [[Data type|type]] equality,<ref>{{cite web | url = https://www.php.net/manual/en/language.operators.comparison.php | title = Comparison Operators | website = [[Php.net]] | access-date = 19 October 2013 | archive-date = 19 October 2013 | archive-url = https://web.archive.org/web/20131019192727/http://php.net/manual/en/language.operators.comparison.php | url-status = live }}</ref> meaning that not only do the two expressions evaluate to equal values, but they are also of the same data type. For instance, the expression {{nowrap|{{code|1=0 == false}}}} is true, but {{nowrap|{{code|1=0 === false}}}} is not, because the number 0 is an integer value whereas false is a Boolean value. [[JavaScript]] has the same semantics for {{code|1====}}, referred to as "equality without type coercion". However, in JavaScript the behavior of {{code|1===}} cannot be described by any simple consistent rules. The expression {{nowrap|{{code|1=0 == false}}}} is true, but {{nowrap|{{code|1=0 == undefined}}}} is false, even though both sides of the {{code|1===}} act the same in Boolean context. For this reason it is sometimes recommended to avoid the {{code|1===}} operator in JavaScript in favor of {{code|1====}}.<ref>{{cite web |last = Crockford |first = Doug |title = JavaScript: The Good Parts |website = [[YouTube]] |date = 27 February 2009 |url = https://www.youtube.com/watch?v=hQVTIJBZook |access-date = 19 October 2013 |archive-date = 4 November 2013 |archive-url = https://web.archive.org/web/20131104115604/http://www.youtube.com/watch?v=hQVTIJBZook |url-status = live }}</ref> In Ruby, equality under {{code|1===}} requires both operands to be of identical type, e.g. {{nowrap|{{code|1=0 == false}}}} is false. The {{code|1====}} operator is flexible and may be defined arbitrarily for any given type. For example, a value of type {{code|Range}} is a range of integers, such as {{code|1800..1899}}. {{nowrap|{{code|1=(1800..1899) == 1844}}}} is false, since the types are different (Range vs. Integer); however {{nowrap|{{code|1=(1800..1899) === 1844}}}} is true, since {{code|1====}} on {{code|Range}} values means "inclusion in the range".<ref>{{cite book |title = [[why's (poignant) Guide to Ruby]] |chapter = 5.1 This One's For the Disenfranchised |author = why the lucky stiff |author-link = why the lucky stiff |chapter-url = http://mislav.uniqpath.com/poignant-guide/book/chapter-5.html#section1 |access-date = 19 October 2013 |archive-date = 24 September 2015 |archive-url = https://web.archive.org/web/20150924063735/http://mislav.uniqpath.com/poignant-guide/book/chapter-5.html#section1 |url-status = dead }}</ref> Under these semantics, <code>===</code> is [[Symmetric relation|non-symmetric]]; e.g. <code>1844 === (1800..1899)</code> is false, since it is interpreted to mean <code>Integer#===</code> rather than <code>Range#===</code>.<ref>{{cite web |last = Rasmussen |first = Brett |title = Don't Call it Case Equality |date = 30 July 2009 |url = http://www.pmamediagroup.com/2009/07/dont-call-it-case-equality/ |website = pmamediagroup.com |access-date = 19 October 2013 |archive-url = https://web.archive.org/web/20131021062941/http://www.pmamediagroup.com/2009/07/dont-call-it-case-equality/ |archive-date = 21 October 2013 }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)