Suppose I have String like :
var abc : NSString = \"ABC\"
and I want to check that it is nil or not and for that I try :
if
The null check is really done nice with guard keyword in swift. It improves the code readability and the scope of the variables are still available after the nil checks if you want to use them.
func setXYX -> Void{
guard a != nil else {
return;
}
guard b != nil else {
return;
}
print (" a and b is not null");
}