Code examples from Peter Cooper's Beginning Ruby.
_____________________________________________
If I execute this code...

class Drawing
  def Drawing.give_me_a_circle
    Circle.new
  end
  class Line
  end
  class Circle
    def what_am_i
      "This is a circle"
    end
  end
end

a = Drawing.give_me_a_circle
puts a.what_am_i
a = Drawing::Circle.new
puts a.what_am_i
a = Circle.new
puts a.what_am_i
______________________________________________
I see this output...

This is a circle
This is a circle
ch06.rb:50:in `<main>': uninitialized constant Object::Circle
(NameError)
________________________________________________________
The output surprises me.  I was expecting an error when ruby executed "a
= Circle.new" because the code is trying to instantiate a class within a
class, without the proper access.  However, I was expecting a second
error when the compiler tries to execute "puts a.what_am_i".
Is it normal for the ruby interpreter/compiler to stop execution and
error output on the first error?
I also noticed that correct code will not be executed after that first
error.

Thanks,
Doug

-- 
Posted via http://www.ruby-forum.com/.