Last active
January 20, 2020 04:27
-
-
Save emmettna/851a251abb6d3a7e878e3a4172357f7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val five = 5 | |
five match { | |
case v if v > 5 => ??? | |
case v if v == 5 => ??? | |
case v if v < 5 => ??? | |
} | |
// more practical example | |
final case class FeeInquiry(user: UserId, amount: BigDecimal, currency: Currency) | |
val requestedFee: Option[FeeInquiry] = ??? | |
requestedFee match { | |
case Some(FeeInquiry(user, amount, currency) if currency === Currency.USD => | |
Right(amount) | |
case Some(FeeInquiry(user, amount, currency) if currency === Currency.__ => | |
Left("We can't accept other than USD") | |
case None => Right(BigDecimal(0)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment