我不明白为什么 scala 有时需要我将 args 命名为 anon fns:
scala> case class Person(name: String)
defined class Person
scala> def reverseString(s: String) = s.reverse
reverseString: (s: String)String
scala> val p = Some(Person("foo"))
p: Some[Person] = Some(Person(foo))
scala> p map { reverseString(_.name) }
<console>:12: error: missing parameter type for expanded function ((x$1) => x$1.name)
p map { reverseString(_.name) }
// why does it only work when I name the argument? I'm not even telling it the type.
scala> p map { p => reverseString(p.name) }
res9: Option[String] = Some(oof)
// and shouldn't this fail too?
scala> p map { _.name.reverse }
res13: Option[String] = Some(oof)