Skip to content

Instantly share code, notes, and snippets.

@fozoglu
Created February 16, 2017 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fozoglu/b1758a7dddb280569d1712212cdb671b to your computer and use it in GitHub Desktop.
Save fozoglu/b1758a7dddb280569d1712212cdb671b to your computer and use it in GitHub Desktop.
Guard kullanımı ile ilgili ufak bir örnek
func writeLabel(firstTextfield: String) -> Int {
guard let d : Int = Int(firstTextfield) else {
let d : Int = 0
print("Değer Yok")
return d
}
print(d)
return d
}
writeLabel(firstTextfield: "5") // Print : 5
writeLabel(firstTextfield: "0") // Print : Değer Yok
writeLabel(firstTextfield: "asdf") // Print : Değer Yok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment