Swift Programming Language

31 thoughts
last posted Aug. 6, 2014, 9:41 p.m.

20 earlier thoughts

0

One thing is clear: Swift has a lot of syntactic sugar.

reversed = sort(names, >)

means

reversed = sort(names, { $0 > $1 } )

which means

reversed = sort(names, { a, b in a > b } )

which means

reversed = sort(names, { a, b in return a > b } )

which means

reversed = sort(names, { (a: String, b: String) -> Bool in return a > b } )

which is the same as:

func backwards(a: String, b: String) -> Bool {
    return a > b
}
reversed = sort(names, backwards)

and none of that even makes use of trailing closure syntactic sugar yet!

10 later thoughts