I\'ve been trying to get this function to return a Bool value but I don\'t understand why i\'m getting the error \"missing return in a function expected to return \'Bool\'. I\'v
I suspect the compiler requires a return value for the case when the loop is not executed at all.
Now, a ClosedRange
can never be empty, so b[0]...b.endIndex
won't ever be empty (if it results in an empty or invalid range, the code would crash), but the compiler is not smart enough to know that.
PS: Are you sure b[0]...b.endIndex
is actually the sequence you want to loop over. This creates a range from the first element of b
to the endIndex of b
. That doesn't make any sense to me.