Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.33 KB | None | 0 0
  1. sealed trait Type
  2. object Apple extends Type
  3. object Orange extends Type
  4. object Potato extends Type
  5.  
  6. object Item {
  7.   def join(i1: Item, i2: Item): Item = Item(i1.t, i1.amount + i2.amount)
  8. }
  9. case class Item(t: Type, amount: Int)
  10.  
  11. val items = Seq[Item](Item(Apple, 1), Item(Apple, 30), Item(Orange, 1), Item(Apple, 12), Item(Potato, 50))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement