Skip to content

Instantly share code, notes, and snippets.

@kings13y
Created March 23, 2011 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kings13y/883335 to your computer and use it in GitHub Desktop.
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
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