Skip to content

Instantly share code, notes, and snippets.

@bijancn
Last active May 30, 2018 13:59
Show Gist options
  • Save bijancn/36c4f7ab1ffd5aad9a47dcfa5b0dbda6 to your computer and use it in GitHub Desktop.
Save bijancn/36c4f7ab1ffd5aad9a47dcfa5b0dbda6 to your computer and use it in GitHub Desktop.
object Cafe {
def buyCoffee(creditCard: CreditCard): (Coffee, Charge) = {
val cup = new Coffee() // new coffee is created
(cup, Charge(creditCart, cup.price)) // cup and charge is returned
}
}
// Can be created without new keyword
case class Charge(creditCard: CreditCard, amount: Double)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment