On Mar 16, 2013 7:10 AM, "Love U Ruby" <lists / ruby-forum.com> wrote:
>
> Love U Ruby wrote in post #1101762:
> > Hi,
> >
>
> > class A
> > end
> >
> > A.ancestors # => [A, Object, Kernel, BasicObject]
>
> My question is - how does `A` come in the output of `A.ancestors` ?
>

Based on my previous samples:

a.is_a? A #=> true
A.is_a? A #=> false

The first is true because A.ancestors.include? A

You can also do this:

def decl cls
  cls.ancestors.reverse.inject do |p,c|
    puts "class #{c} < #{p}"
    puts 'end'
  end
end
decl A

Note: I've ignored included modules.

Sent from my phone, so excuse the typos.