Skip to content

Instantly share code, notes, and snippets.

@sonumehrotra
Last active December 3, 2020 02:53
Show Gist options
  • Save sonumehrotra/fcd1066fae36f1769176a36380631483 to your computer and use it in GitHub Desktop.
Save sonumehrotra/fcd1066fae36f1769176a36380631483 to your computer and use it in GitHub Desktop.
import Order.Order
object OrderWithWorkaround extends App {
class BuyWithWorkaround(q: Int) extends {
val quantity = q
} with Order
class SellWithWorkaround(q: Int) extends {
val quantity = q
} with Order
object TradeWithWorkaround {
def buy(q: Int): BuyWithWorkaround = new BuyWithWorkaround(q)
def sell(q: Int): SellWithWorkaround = new SellWithWorkaround(q)
}
val buy2 = TradeWithWorkaround.buy(100)
println(buy2.quantity)
println(buy2.printQuantity)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment