4 ms·
The author's comment on the first example is: > what is the type of $0 and $1? Surely a great thing about Swift is that the compiler knows the types of $0 and
by interpol_p 12y ago
The author's comment on the first example is:
> what is the type of $0 and $1?
Surely a great thing about Swift is that the compiler knows the types of $0 and $1 and will prevent you from doing stupid things with them like you can in Obj-C?
- dirtyaura 12y agoYes, and having lambdas and unnamed parameters is a great thing when the local context is enough to explain it. People are totally okay working with unnamed numbers and values, and it is as important with functions when you program in functional way. We write x2 = x1 + 10 if it makes sense in the context. When it needs a better explanation we name the value width = 10 ... x2 = x1 + width If we would need to name EVERY number, the code would be less readable. Same with the functions, sometimes lambda with unnamed parameters (e.g. $0 < $1) is more readable than naming the lambda and all the parameters. Each name adds a conceptual burden.