title: How to return a value from a Scala def
body: <p>I am new to Scala, but have some experience with Haskell. I did the following:</p>
  
  <pre><code>import scala.io.Source
  
  val fileContent = Source.fromFile(filename).getLines.toList
  val content = fileContent.map(processLine)
  
  def processLine(line: String){
      val words = line.split("\\s+")
      println((words(0), words(1))) 
  }
  </code></pre>
  
  <p>Here processLine doesn't return anything so content is now a list of empty return values for all items. I thought the solution would be to include a return value in processLine, but Scala doesn't like that:</p>
  
  <pre><code>warning: enclosing method processLine has result type Unit: return value discarded
  </code></pre>
  
  <p>So how can I modify processLine so that it can be used to create a list of non-empty tuple values in content? how would it be to declare a lambda function with more than one line?</p>
  
  <p>Thanks to helpful info in this thread, I could also have written it with a lambda expression:</p>
  
  <pre><code>var nonLinearTrainingContent = fileContent.map(x=&gt; {
          val words = x.split("\\s+")
          (words(0), words(2))
          })
  </code></pre>