0

Reading lines from file I try to use curried function in 'foreach' :

import scala.io.Source
object CurriedTest {

  def main(args: Array[String]): Unit = {
    fun("one")("two")("three")
    (fun2)("three")
    val lst = List ("x", "y", "z")
    lst.foreach(fun2) 
    lst.foreach(fun("000")("111") ) 
    Source.fromFile(args(0)).getLines.foreach(fun("AAA")("BBB") _)    
    Source.fromFile(args(0)).getLines.foreach(fun2)
  }

  def fun (a1: String) (a2:String) (a3: String) = {
    println("a1: "+a1+" a2: "+a2+" a3: "+a3)
  }

  def fun2 = fun("one")("two") _
}

For some reason neither of the following statements:

    Source.fromFile(args(0)).getLines.foreach(fun("AAA")("BBB") _)    
    Source.fromFile(args(0)).getLines.foreach(fun2)

produce any output. Why?

duplode
  • 33,731
  • 7
  • 79
  • 150
DarqMoth
  • 603
  • 1
  • 13
  • 31

1 Answers1

0

I found the answer. I was reading an empty file which naturally produced an empty output. Sorry for the confusion.

DarqMoth
  • 603
  • 1
  • 13
  • 31