Scalastyle (intellij 2016.1 defaults) says this boolean expression can be simplified
val t = Option(true) val f = Option(false) if(t.contains(true) && f.contains(false)) { println("booop") }
I can get rid of this by changing the if to:
if(t.contains(true).&&(f.contains(false)))
Or by changing && to &
But I donβt really see how this simplifies it, can anyone explain what is happening?
Update It does not appear to be related to whether the shafts are known at compile time or locally defined. The following code also receives a warning that the expression can be simplified:
object TestFoo { def bar(t: Option[Boolean]) = { val f = Option(scala.util.Random.nextBoolean) if (t.contains(true) && f.contains(false)) println("booop") } def main(args: Array[String]) = bar(t = Option(scala.util.Random.nextBoolean)) }
I just donβt understand how I should make this simpler, is there some strange [Boolean] option comparing me missing?
klogd source share