That's expected. If you change "sealed override" to just "override" the method 
is virtual and Ruby subclasses will override it.
In both cases NewSquare.new.GetNumberOfSizes finds CLR method 
Square::GetNumberOfSizes and invokes it. In the first case, the method is not 
overridden and therefore the implementation in Square gets executed. Without 
"sealed" the method is overridden by NewSquare#get_number_of_sizes and 
therefore the virtual dispatch executes NewSquare's implementation. 

In both cases NewSquare.new.get_number_of_sizes finds Ruby method 
NewSquare#get_number_of_sizes and executes it.

Tomas

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Shay Friedman
Sent: Saturday, June 13, 2009 12:03 PM
To: [email protected]
Subject: Re: [Ironruby-core] Sealed method can be overriden

There is a slight difference though.
In the example:
puts NewSquare.new.get_number_of_sizes # => 99
puts NewSquare.new.GetNumberOfSizes # => 4


If I change the example to a regular method (not sealed), the output is 
slightly different:
puts NewSquare.new.get_number_of_sizes # => 99
puts NewSquare.new.GetNumberOfSizes # => 99

Thanks,
Shay.

----------------------------
Shay Friedman
http://www.ironshay.com
Follow me: http://twitter.com/ironshay
-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to