Take this code:
class Register(var value:Int = 0) {
def getZeroFlag() : Boolean = (value & 0x80) != 0
}
object Register {
implicit def reg2int(r:Register):Int = r.value
implicit def bool2int(b:Boolean):Int = if (b) 1 else 0
}
I want to use it like so:
val x = register.getZeroFlag + 10
but I am greeted with:
type mismatch; found : Boolean required: Int
What goes? Do I need to define a implicit taking a function that returns a bool?