Last active
December 3, 2020 02:53
-
-
Save sonumehrotra/fcd1066fae36f1769176a36380631483 to your computer and use it in GitHub Desktop.
This file contains 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
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