I would like to do a pattern match that looks like :
sinceOp match {
case None |Some(lastUpdate) if lastUpdate<= update.time =>
Saddly this does not work. Any ideas ?
Thanks
You could can also test the reverse condition:
sinceOp match {
case Some(lastUpdate) if lastUpdate > update.time => //...
case _ => //...
}
The second case covers both None
and the case where the last update is smaller.
Or you can replace pattern matching with chain of functions
sinceOp.filterNot(_ <= update.time).getOrElse(println("if None"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With