Using guard with a non-optional value assignment

后端 未结 1 1239
余生分开走
余生分开走 2020-12-31 21:11

I like using guard because it makes your intensions clear. I\'ve used it both for the optional version like this...

guard let c = MyOptionalArra         


        
相关标签:
1条回答
  • 2020-12-31 21:39

    If you throw a case in there, it'll work. So as follows:

    guard case let c = parts.count where c > 1 else { return }
    
    0 讨论(0)
提交回复
热议问题