Created
June 12, 2014 03:12
-
-
Save debreuil/575c40c15640e13b2e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you compare tuples for equality? | |
var tupleA = (1, "one") | |
var tupleB = (1, "one") | |
// tup == tup2 // error: tuples can not be compared with ==, can not be used as hash key etc | |
// If you need to test for object equality, a tuple is not suitable | |
tupleA.0 == tupleB.0 && tupleA.1 == tupleB.1 // but you can do this | |
// you can also use element names | |
var tupleC = (a:1, b:"one") | |
tupleA.0 == tupleC.a && tupleA.1 == tupleC.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment