Kodeco Forums

Swift Style Guide: April 2015 Update

We have updated our popular Swift style guide for Swift 1.2, along with a number of other changes - find out what's changed!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1883-swift-style-guide-april-2015-update

Sorry if I misplaced this, I have a question on variables declaration with initial values. According to the style guide, the proper way would be:
let maximumWidth: CGFloat = 106.5
My opinion is that:
let maximumWidth: CGFloat(106.5)
is better because it uses a designated initializer and it’s similar with structs initialization (eg. CGRect). What do you think?

Good point, and in fact CGFloat is a struct in Swift. However we all know what it means and this way conforms to the principle of preferring compact code.