How do I get the parent's class name in Ruby -
let assume have classes a
, b
b
inherits a
. how print parent class name in b
class end class b < end
some things have tried
>> b.new.class #=> b #which right >> b.new.parent #=> undefined method `parent` >> b.parent #=> object >> b.parent.class #=> class
thanks :)
class end class b < end b.superclass # => b.superclass.name # => "a"
ruby
No comments:
Post a Comment