Reputation: 1
I have defined a function in swift that will take two strings as parameters and return true if they are the same:
func compareString(f_string:String,S_string:String)->Bool{
if f_string == S_string{
return true
}
}
Why does it show an error message?
Upvotes: 0
Views: 285
Reputation: 744
your function is supposed to return a boolean value everytime, but it returns only when the strings are equal. add a return false statement after if and it should work.
func compareString(f_string:String,S_string:String)->Bool{
if f_string == S_string{
return true
}
return false
}
Upvotes: 2