Skip to content

Instantly share code, notes, and snippets.

@jonathanpenn jonathanpenn/js.swift
Last active Oct 25, 2016

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Jun 6, 2014

$ jsc
>>> NaN != NaN
true
@garybernhardt

This comment has been minimized.

Copy link

commented Jun 7, 2014

now swift is ready to scale

@brianewing

This comment has been minimized.

Copy link

commented Jun 7, 2014

web scale™

@jonathanpenn

This comment has been minimized.

Copy link
Owner Author

commented Jun 8, 2014

@kevin1 fixed!

@JensAyton

This comment has been minimized.

Copy link

commented Jun 8, 2014

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
You can’t perform that action at this time.