Lets assume that I have a plain third party (i.e. I cannot modify it) class defined like:
class Price(var value: Int)
Is this possible to m
Thinked about accepting flavian's solution but came up with slightly better one by myself.
Here is how one could implement printPrice (without need to use wrapper objects and modifying original class):
def printPrice(price: Price) = price match {
case p: Price if (p.value <= 9000) => println("price is " + p.value)
case p: Price => println("price is over 9000")
}
PS: credits to flavian for showing that you can use if in pattern. Upvoting your answer for this.