Take a look at this:
class MC
def happy; print "C"; super if defined?(super); end
end
module M
def happy; print "M"; super if defined?(super); end
end
class S < MC
include M
def happy; print "x"; super if defined?(super); end
end
s = S.new
print "superclass: "; s.happy
print "\t", class << s; self; end.ancestors.inspect; puts
Outputs:
superclass: xM [S, M, MC, Object, Kernel]
Now look at this:
class MC
def happy; print "C"; super if defined?(super); end
end
module M
def happy; print "M"; super; end
end
class S < MC
include M
def happy; print "x"; super if defined?(super); end
end
s = S.new
print "superclass: "; s.happy
print "\t", class << s; self; end.ancestors.inspect; puts
Outputs:
superclass: xMC [S, M, MC, Object, Kernel]
The last is what one would expect. Seems that defined?(super) dosen't work
with mixins even though calling super does. What do you make of that? Bug?
T.