Created
September 4, 2015 16:39
-
-
Save tobnee/ca2bb15afed30695e30e to your computer and use it in GitHub Desktop.
Event evolutions as fold over evolution functions
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
val evolutions = List( | |
(v: JsObject) => v + ("a" -> JsString("foo")), | |
(v: JsObject) => v + ("b" -> JsNumber(2)), | |
(v: JsObject) => v - "a" | |
) | |
//evolutions: List[play.api.libs.json.JsObject => play.api.libs.json.JsObject] = List(<function1>, <function1>) | |
evolutions.foldLeft(Json.obj("msg" -> "Nice Evolution"))((value, evolution) => evolution(value)) | |
// res1: play.api.libs.json.JsObject = {"msg":"Nice Evolution","b":2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment