+ 1
Declairing empty variables SWIFT
I'm able to declare an empty variable like var airport: String So why do I see everyone doing it this way? var airport = String () and yes I know to adding a "?" at the end of my declarration turns it to nil until it's initialized.
1 Answer
+ 2
var airport = String () is the same as var airport: String, both are creating a null variable of type String. The reason people create their variables this way is because they are familiar with other languages that use this somewhat similar method without parentheses.
So don't worry about creating your null variable on your way, because it's correct too !