Hi I\'m just trying out my first bits of scala and have hit this error which I don\'t understand. I\'ve been trying to work it out and have exhausted my ideas. Help?
<
You have to have an else
clause, otherwise the type checker doesn't know what the return type is when it's not the case that count<0
.
def calculate(count: Int): Boolean =
if (count<0) false
else true
Or, better yet, you don't need the if-statement at all:
def calculate(count: Int) = count >= 0