Skip to content

Instantly share code, notes, and snippets.

@flurdy
Created January 24, 2016 18:18
Show Gist options
  • Save flurdy/286e4758bd9c71432bda to your computer and use it in GitHub Desktop.
Save flurdy/286e4758bd9c71432bda to your computer and use it in GitHub Desktop.
Boolean Fold in Scala
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