0

Switching to Swift 3, in XCode 8.0, forced unwrapping changed as described in the playground code below:

var i: Int!
i = 0
print("\(i)") // -1 outputs "Optional(0)\n" 

var j = i
j = 0
print("\(j)") // -2 still "Optional(0)\n" 

var k: Int = i
print(k)      // -3 outputs "0\n" 

var l: Int = j // -4 error: Value of optional type 'Int?' not unwrapped; did you mean to use '!' or '?'?
print(l)

In swift 2, this used to output only "0\n" (without Optional(), and without compilation error.)

Seems like a bug to me. Or am I missing something in the Swift 3?

CMont
  • 690
  • 6
  • 13
  • 1
    https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md – Leo Dabus Sep 20 '16 at 07:48
  • 3
    Related: [Swift 3 incorrect string interpolation with implicitly unwrapped strings](http://stackoverflow.com/questions/39537177/swift-3-incorrect-string-interpolation-with-implicitly-unwrapped-strings) – Hamish Sep 20 '16 at 08:02
  • Thanks, I had not found any related post before sending my question. – CMont Sep 21 '16 at 00:51

0 Answers0