Skip to content

Instantly share code, notes, and snippets.

@nicholasf
Created June 7, 2015 22:51
Show Gist options
  • Save nicholasf/cba59bb85adf779b8d1f to your computer and use it in GitHub Desktop.
Save nicholasf/cba59bb85adf779b8d1f to your computer and use it in GitHub Desktop.
scala> foo
res7: Array[String] = Array(one, two, three)
scala> foo.foldLeft(List[String]()) { (z, f) => z :+ f.toUpperCase }
res8: List[String] = List(ONE, TWO, THREE)
scala> foo.foldRight(List[String]()) { (z, f) => z :+ f.toUpperCase }
<console>:9: error: value toUpperCase is not a member of List[String]
foo.foldRight(List[String]()) { (z, f) => z :+ f.toUpperCase }
^
scala> foo.foldRight(List[String]()) { (f, z) => z :+ f.toUpperCase }
res10: List[String] = List(THREE, TWO, ONE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment