Skip to content

Instantly share code, notes, and snippets.

@jonathanpenn
Last active October 25, 2016 11:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanpenn/c69e7b8485e29ffff598 to your computer and use it in GitHub Desktop.
Save jonathanpenn/c69e7b8485e29ffff598 to your computer and use it in GitHub Desktop.
So the JavaScript developers feel right at home...
class NaNClass {}
let NaN = NaNClass()
@infix func == (n1: NaNClass, n2: NaNClass) -> Bool {
return false
}
@infix func != (n1: NaNClass, n2: NaNClass) -> Bool {
return true
}
@infix func + (a1: Array<Any>, a2: Array<Any>) -> String {
return ""
}
NaN == NaN // -> false
NaN != NaN // -> true
[] + [] // -> ""
@kevin1
Copy link

kevin1 commented Jun 6, 2014

$ jsc
>>> NaN != NaN
true

@garybernhardt
Copy link

now swift is ready to scale

@brianewing
Copy link

web scale™

@jonathanpenn
Copy link
Author

@kevin1 fixed!

@JensAyton
Copy link

import Foundation // Is there another way to get the C standard library?
let a = atan(4)
a == a // false
a === a // error, although to be fair it does the wrong thing in JS
a is a // meaningless in Swift, does the right thing in JS Harmony

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment