franklinchou / fp-in-scala

My solutions to the book Functional Programming in Scala
0 stars 0 forks source link

Higher order functions #11

Open franklinchou opened 5 years ago

franklinchou commented 5 years ago

https://danielwestheide.com/blog/2013/01/23/the-neophytes-guide-to-scala-part-10-staying-dry-with-higher-order-functions.html

franklinchou commented 5 years ago

See also https://danielwestheide.com/blog/2012/12/12/the-neophytes-guide-to-scala-part-4-pattern-matching-anonymous-functions.html

franklinchou commented 5 years ago

You must specify the value when pattern matching on anonymous functions, i.e.,

val predicate: ((String, String)) => Boolean = {
  case (_, f) => f > 3 && f < 25
}

Here, the type, ((String, String)) => Boolean must be provided. The compiler cannot infer types for pattern matched anonymous functions.