title: calling println on a user defined function formatResult 3 times from main, but execution order is different
body: <p>I am very new to Scala. I tried calling formatResult inside println 3 times from main passing abs, fact, fib in that order.</p>
  
  <p>But the output shows a different execution order - fact, fib, abs</p>
  
  <p>/* MyModule.scala */</p>
  
  <pre><code>object MyModule {
  
      def abs(n: Int): Int = 
          if(n &lt; 0)
              -n
          else
              n
  
      def fact(n: Int): Int = {
          def go(n: Int, acc: Int): Int = {
              if(n &lt;= 1)
                  acc
              else
                  go(n - 1, n * acc)
          }
  
          go(n, 1)
      }
  
      def fib(n: Int): Int = {
          def loop(n: Int, prev: Int, curr: Int): Int = {
              if(n == 0)
                  prev
              else
                  loop(n - 1, curr, prev + curr)
          }
  
          loop(n, 0, 1)
      }
  
      private def formatResult(fName: String, placeholder: String, n: Int, f: Int =&gt; Int) = {
          val msg = "The %s %s %d is %d"
          msg.format(fName, placeholder, n, f(n))
      }
  
      def main(args: Array[String]): Unit = 
  
          println(formatResult("absolute value", "of", -10, abs))
          println(formatResult("factorial", "of", 5, fact))
          println(formatResult("fibonacci number", "at index", 8, fib))
  }
  </code></pre>
  
  <p>/* output */</p>
  
  <pre><code>The factorial of 5 is 120
  The fibonacci number at index 8 is 21
  The absolute value of -10 is 10
  </code></pre>
  
  <p>Could someone please explain this to me?</p>