class Fracpri
attr_accessor:whole, :numer, :denom, :dec, :flofrac
def initialize()
puts \"Hey! It\'s an empty constructor\"
end
def getFraction(whole,numer,denom)
It is not possible to override =
, nor variants such as +=
. These are built in keywords and not methods such as +
.
If you change your patch from def +=(obj)
to def +(obj)
, you can still call r1 += r2
and it will have the same effect as if you'd patched +=
. This is because +=
is calling your patched +
method under the hood.
By the way, your +
method doesn't actually return a value so any time you call +=
it will always result in nil .... but it seems like this is still a WIP so hopefully you can sort that bit out.