Skip to content

Commit

Permalink
simpler TournamentClock.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 29, 2024
1 parent 293a05c commit faf219e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/scala/TournamentClock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ object TournamentClock:
TournamentClock(limit, IncrementSeconds(b))

def apply(str: String): Option[TournamentClock] =
val clean = cleanRegex.replaceAllIn(str.toLowerCase, "").replace(" ", "")
clean.toIntOption
.map(make(_, 0))
.orElse:
clean.split('+') match
case Array(a, b) => (a.toIntOption, b.toIntOption).mapN(make)
case _ => none
cleanRegex
.replaceAllIn(str.toLowerCase, "")
.replace(" ", "")
.split('+') match
case Array(a) => a.toIntOption.map(make(_, 0))
case Array(a, b) => (a.toIntOption, b.toIntOption).mapN(make)
case _ => none

0 comments on commit faf219e

Please sign in to comment.