Ruby Reflective language

Reflective language

# A reflective programming language --
# one in which the active environment can query the objects
# that define itself and extend or modify them at runtime.

puts "abc".class  # Prints String
puts 345.class  # Prints integer constant

class Animal
end

class Dog < Animal
end

rover = Dog.new
puts rover.class  # Prints Dog

if rover.is_a? Dog
   puts "Of course he is."
end

if rover.kind_of? Dog
   puts "Yes, still a dog."
end

if rover.is_a? Animal
   puts "Yes, he's an animal, too."
end