guard基本使用

26. January 2016 Swift 0

import Foundation

func checkup(person:[String:String]){

guard let id = person[“id”] else{

print(“请输入用户名”)

return

}

guard let examNumber = person[“examNumber”] else {

print(“请输入密码”)

return

}

print(“您的身份证号为:\(id),准考证号为:\(examNumber)”)

}

//checkup([“id”:”123456″])

//checkup([“examNumber”:”654321″])

checkup([“id”:”123456″,”examNumber”:”654321″])


Leave a Reply

Your email address will not be published. Required fields are marked *