syntax - Swift 1.2: Obnoxious snippet shows Types can be shadowed by variable identifiers -


why allowed in swift:

// swift 1.2, xcode 6.4, os x 10.10.4 // running within ios app, not playground func wtf() {     var string = 3     var int = "3a"     println(string) // outputs 3     println(int)    // outputs 3a     println(int.toint()) // outputs nil; acting string     // var x: string = "abc" // not ok: 'string' not type } 

types , variable bindings can intefere each other? fundamental types?

in "real" environment (not playground) error message in 1st line --> use of local variable 'int' before declaration

if comment out 1st line, code compiles , after adding lines print x , y get

swift.string 3 optional(3) abc abc 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -