Re:Swift, the new way to build iOS Apps. Here's how
by rubiquity on Tuesday June 03, 2014 @11:10AM
(#7840645)
And yet you've managed to shed no light on how constants should be used in Swift.
[ Parent
| on HN ]
Re:Swift, the new way to build iOS Apps. Here's how
by andrewmunsell on Tuesday June 03, 2014 @11:31AM
(#7840781)
To shed some light on the practice of using `let` vs. `var`, an excerpt from the book by Apple:
“If a stored value in your code is not going to change, always declare it as a constant with the let keyword. Use variables only for storing values that need to be able to change.”
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l
Re:Swift, the new way to build iOS Apps. Here's how
by jquave on Tuesday June 03, 2014 @12:02PM
(#7840974)
Thanks Andrew, I am updating the posts as I learn more. We're all still learning.
Re:Swift, the new way to build iOS Apps. Here's how
by gress on Tuesday June 03, 2014 @02:50PM
(#7842061)
Let is fine for defining constants, but it should also be used whenever possible for two reasons:
1. It gives you additional safety against accidental reassignment.
2. It gives the compiler a major optimization hint since the value is not a variable.