Last active
August 26, 2016 22:04
-
-
Save sam/739633f616c57ae312e7cc377443e183 to your computer and use it in GitHub Desktop.
A trivial, common example and for-comprehensions failing at it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fold | |
client ! Projects(rows.headOption.fold(Nil)(_ \ "value" extract)) | |
// map.getOrElse | |
client ! Projects(rows.headOption | |
.map(_ \ "value" extract) | |
.getOrElse(Nil)) | |
// Option.toList | |
client ! Projects(rows.headOption.toList.map(_ \ "value" extract)) | |
// for-comprehension | |
client ! Projects(for { head <- rows.headOption.toList } yield head \ "value" extract) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment