mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 00:38:46 +02:00
simplify Option expression
`collectFirst` is a deprecated method, I believe my suggestion is simpler.
This commit is contained in:
parent
ec83d01dca
commit
aba77af6fb
|
@ -4,10 +4,7 @@ case class UserAge(ageInYears: Option[Int]) {
|
|||
def hasAge: Boolean = ageInYears.isDefined
|
||||
|
||||
def isGte(ageToCompare: Int): Boolean =
|
||||
ageInYears
|
||||
.collectFirst {
|
||||
case age if age > ageToCompare => true
|
||||
}.getOrElse(false)
|
||||
ageInYears.exists(_ > ageToCompare)
|
||||
|
||||
def unapply(userAge: UserAge): Option[Int] = {
|
||||
ageInYears
|
||||
|
|
Loading…
Reference in New Issue
Block a user