ruby 1.8.7(2010-12-23 patchlevel 330)[i686-darwin10.5.0]
我错过了什么吗?
module Mixin
def is_a?(o)
return false if o == Hash
super
end
alias_method :kind_of?, :is_a?
end
class Doc < Hash
include Mixin
end
puts Doc.new().is_a?(Doc) # => true
puts Doc.new().kind_of?(Doc) # => super: no superclass method `is_a?'
预期:
puts Doc.new().is_a?(Doc) # => true
puts Doc.new().kind_of?(Doc) # => true
puts Doc.new().is_a?(Hash) # => false
puts Doc.new().kind_of?(Hash) # => false
rubinius和ruby 1.9.2p136
上的一切都很酷