Swift3 optionals chaining in IF conditions bug?

后端 未结 4 677
感动是毒
感动是毒 2020-12-01 20:01

This code worked just fine in Swift 2.3 and I don\'t understand why I have to unwrap TestClass to check if number is bigger than 4. This is whole point of chain

4条回答
  •  温柔的废话
    2020-12-01 20:52

    Optional comparison operators are removed from Swift 3. SE-0121

    You need to write something like this:

    if test?.optionalInt ?? 0 > 4
    {
    
    }
    

提交回复
热议问题