if let - ShenYj/ShenYj.github.io GitHub Wiki

if let

通常在使用可选项变量时,会使用相同名称,如

  • guard

    guard let tapClource = tapClource else { return }
  • if let 也是一样

    if let tapClource = tapClource { ... }

Swift 5.7 下语法简化, 可以省略一部分了

  • guard

    guard let tapClource else { return }
  • if let 也是一样

    if let tapClource  { ... }

这个语法优化看起来还不错

⚠️ **GitHub.com Fallback** ⚠️