Instance variables in subclasses sometimes are defined incorrectly
wagenet opened this issue · 2 comments
wagenet commented
In my specific case, it is overwriting the parent type with something overly specific:
class Base
@warnings_suppressed: bool
end
class Subclass < Base
@warnings_suppressed: bot
end
Rough code:
class Base
def initialize
@warnings_suppressed = false
end
def suppress_warnings!
tap { @warnings_suppressed = true }
end
def warn(message, event = nil)
return if @warnings_suppressed
puts message
end
end
class Subclass < Base
def do_stuff
warn("Something went wrong")
end
end
wagenet commented
Yes, this should be fixed now.