def bang(x: Int): Int = if (x == 0) throw new Exception("bang!") else bang(x - 1)
def isEven(x: Int): Boolean = if (x == 0) true else isOdd(x - 1) def isOdd(x: Int): Boolean = if (x == 0) false else isEven(x - 1)
val funValue = nestedFun _ def nestedFun(x: Int) { if (x != 0) { println(x); funValue(x - 1) } }
scala> bang(5) java.lang.Exception: bang! at .bang(<console>:5) at .<init>(<console>:6)
Login in to like
Login in to comment
or Read more about Scala Quizzes
Login in to like
Login in to comment