Skip to content

Instantly share code, notes, and snippets.

@ygree
Last active August 29, 2015 13:56
Show Gist options
  • Save ygree/8976279 to your computer and use it in GitHub Desktop.
Save ygree/8976279 to your computer and use it in GitHub Desktop.
object BuilderWrapper {
implicit class BuilderWrapper[B](val b: B) {
def extend(f: B => B): B = f(b)
def extend(cond: Boolean)(f: B => B): B = if (cond) extend(f) else b
def extend[V](opt: Option[V])(f: V => B => B): B = opt map (v => extend(f(v))) getOrElse b
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment