Naming stuff is hard, but more fun than cache invalidation. implicit class BooleanExt(val bool: Boolean) extends AnyVal { def ergo[T](t: T): Option[T] = if(bool) Some(t) else None } if(me.thinks) Some(me) else None or, me.thinks.ergo(me)
-
-
Replying to @propensive @clementd
@guizmaii smarter than your original implicit to go from Boolean to Option ;)1 reply 0 retweets 1 like -
I tend to use `Some(x).filter(_ => myBoolean)` in that case (which is not very common, I avoid booleans like plague)
1 reply 1 retweet 4 likes -
Definitely more functional. Lambdas which don't use their parameter make me uneasy, though...
1 reply 0 retweets 1 like -
Where does the name "ergo" come from ?
2 replies 0 retweets 0 likes
It's Latin, but is used occasionally in English, to the extent that it's English now. https://en.wiktionary.org/wiki/ergo
5:23 AM - 4 Feb 2018
0 replies
0 retweets
1 like
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.