Guest User

Untitled

a guest
Mar 11th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.30 KB | None | 0 0
  1. Question 1:
  2. In the preferred Scala style it almost always possible to avoid using explicit return statements. All expressions return a value so the first function could be written this:
  3.  
  4.  def nthFibonacci(n : Int): Int ={
  5.     if (n == 1 || n == 2) n
  6.     else nthFibonacci(n-1) + nthFibonacci(n-2)
  7.  }
Advertisement
Add Comment
Please, Sign In to add comment