Created
March 23, 2011 15:54
-
-
Save kings13y/883335 to your computer and use it in GitHub Desktop.
Simple example of using an option class with method chaining (fluent builder) and sealed classes
This file contains hidden or 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
sealed abstract class BetType | |
case object BackBet extends BetType | |
case object LayBet extends BetType | |
case class Bet(amount: Int, betType:Option[BetType]) | |
val reservations = List(Bet(100, Option(BackBet)), Bet(200, None)) | |
for(exposure <- reservations) println("Amount exposed: " + exposure.amount + " - type: " + exposure.betType.getOrElse("Reservation") + ".... sample method chaining " + exposure.betType.toString.reverse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment