title: Why does one of these statements compile in Scala but not the other?
body: <p>(<strong>Note</strong>: I'm using Scala 2.7.7 here, not 2.8).</p>
  
  <p>I'm doing something pretty simple -- creating a map based on the values in a simple, 2-column CSV file -- and I've completed it easily enough, but I'm perplexed at why my first attempt didn't compile.  Here's the code:</p>
  
  <pre><code>// Returns Iterator[String]
  private def getLines = Source.fromFile(csvFilePath).getLines
  
  // This doesn't compile:
  def mapping: Map[String,String] = {
      Map(getLines map { line: String =&gt;
            val pairArr = line.split(",")
            pairArr(0) -&gt; pairArr(1).trim()
          }.toList:_*)
    }
  
  // This DOES compile
  def mapping: Map[String,String] = {
      def strPair(line: String): (String,String) = {
        val pairArr = line.split(",")
        pairArr(0) -&gt; pairArr(1).trim()
      }
      Map(getLines.map( strPair(_) ).toList:_*)
    }
  </code></pre>
  
  <p>The compiler error is </p>
  
  <blockquote>
    <p>CsvReader.scala:16:
    error: value toList is not a member of
    (St ring) => (java.lang.String,
    java.lang.String)    [scalac] possible
    cause: maybe a semicolon is missing
    before `value toList'?    [scalac]<br>
    }.toList:_*)    [scalac]           ^<br>
    [scalac] one error found</p>
  </blockquote>
  
  <p>So what gives?  They seem like they should be equivalent to me, apart from the explicit function definition (vs. anonymous in the nonworking example) and () vs. {}.  If I replace the curly braces with parentheses in the nonworking example, the error is "';' expected, but 'val' found."  But if I remove the local variable definition and split the string twice AND use parens instead of curly braces, it compiles.  Can someone explain this difference to me, preferably with a link to Scala docs explaining the difference between parens and curly braces when used to surround method arguments?</p>