Skip to content

Instantly share code, notes, and snippets.

@debreuil
Created June 12, 2014 03:12
Show Gist options
  • Save debreuil/575c40c15640e13b2e74 to your computer and use it in GitHub Desktop.
Save debreuil/575c40c15640e13b2e74 to your computer and use it in GitHub Desktop.
// 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