0
is is allowed to optionally mention type in swift ?
is there any optional way to declare the value type like java.. for example in typescript u can declare just using var or mention type too. can same thing happen in swift or no
1 Antwort
+ 2
Yes you can cause swift can guess and infer the type:
var a = "swift"
// later in code
a = 10 // will cause an error.because a is a string and it's value was "swift"
var b: Bool = false is the same as var b = false