swift - How do i create an optional var with no value inline -
i have method returns optional integer one:
func foo(bar:string) -> int? { if(bar == "bar") { return 42 } else { var nothing:int? return nothing } }
i'd return no value without creating var, possible?
return nothing:int?
would expect...
thanks in advance.
use
return nil
you not need specify type - have provided in function return type already.
Comments
Post a Comment