-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid defining a value's type if it can be inferred #13
Comments
Never define the type if it can be inferred. |
Take into account the fact that specifying the type adds clarity and do so only when such clarity is needed. This opens a whole new can of worms. A comment I got a few times is that this style is useful in hte properties list of a type, so: Always define the type when listing properties for a type |
For @mokagio to admit this is just a pet peeve of his, and forget about it. |
There's also one thing I saw: view.color = UIColor.red I think the information of UIColor is redundant as well. So idealy: view.color = .red |
Found a good article talking about this. (But couldn't locate it now). This does in a way affect our Xcode build time due to how its inference engine works. We can make it work less by putting in the type. But hey, who knows future Xcode will improve on this. |
Here and there in the codebase we have some code doing:
In such cases the type information is redundant, the compiler can infer it, an so can the reader.
A point has been made that this style provide more clarity, I can see that point, although I personally disagree.
I have a 3 suggestions which I'll list as single comments so that they can be 👍 ed.
The text was updated successfully, but these errors were encountered: