Created
January 24, 2016 18:18
-
-
Save flurdy/286e4758bd9c71432bda to your computer and use it in GitHub Desktop.
Boolean Fold in Scala
This file contains hidden or 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
package object models { | |
implicit class BooleanFold(boolean: Boolean){ | |
def fold[B](l: B)(r: B => B): B = if(boolean) r(l) else l | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment