Questions tagged «guard-statement»

13
斯威夫特的后卫关键字
Swift 2引入了guard关键字,该关键字可用于确保已准备好配置各种数据。我在此网站上看到的示例演示了一个commitTapped函数: func submitTapped() { guard username.text.characters.count > 0 else { return } print("All good") } 我想知道使用条件guard是否与使用老式方法使用if条件有所不同。它会带来好处吗?使用简单的支票无法获得这些好处?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.