In a little bit of accidental Scala REPL fun this afternoon, I was testing a recursive algorithm like the following simple factorial algorithm, and forgot a return statement:
def factorial(n: Int):Int = {
if (n == 1) n // forgot 'return' here
factorial(n - 1)
}
When I pasted that code into the Scala REPL and then tried to test it as shown below, it didn't come back for a while, until it failed with this error message: