Closed ColinEberhardt closed 10 years ago
I have a feeling I'm going to end up just saying :+1: to all of these issues :]
Following the general trend of immutability by default in Objective-C, I think this is a good idea.
Use let
unless it needs to be a var
. :-)
EDIT: I'd even say, Use let
unless this results in a compiler error. (Or at least, unless the compiler won't let you.)
I don't think this is even a style issue. Apple said to use let for all constants. The compiler apparently produces faster code that way.
To get into the habit, I'm typing let all the time and then only changing to var when I find myself trying to change a value.
Sent from my iPhone
On Jun 10, 2014, at 3:55 AM, Matthijs Hollemans notifications@github.com wrote:
Use let unless it needs to be a var. :-)
— Reply to this email directly or view it on GitHub.
I agree, we should use let
for all constants.
I'm currently converting a SpriteKit demo app to Swift and it's not using var
anywhere. :-)
Agreed, and especially important when using collections
:+1:
:+1:
I find myself using
let
for constant class properties, but often forget that you can uselet
for constants within the scope of functions.My proposal is that
let
is used for any value that is a constant.