You'll be able to override anything in ruby - you'll find CLR classes harder to fool. Try creating a C# method that accepts a Shape and calls the GetNumberOfSizes() method - I expect you'll find that the NewSquare override is ignored and the Square method is called instead.
I was surprised to find that a non virtual property in a C# class was able to be replaced by defining a new one in ruby (this was not the case for a non virtual method) - see http://github.com/markryall/orangutan/blob/412913de26b9d545ebf08b2a1367e6675f8625f7/spikes/experiment1.rb Mark. On Sat, Jun 13, 2009 at 6:22 PM, Shay Friedman <[email protected]> wrote: > Hi guys, > > I'm trying to override a sealed method in IR and I succeed. > > For example: > C#: > public class Shape > { > public virtual int GetNumberOfSizes() { return 0; } > } > public class Square : Shape > { > public override sealed int GetNumberOfSizes() { return 4; } > } > > IR: > class NewSquare < Square > def get_number_of_sizes > return 99 > end > end > puts NewSquare.new.get_number_of_sizes # => 99 > > Bug or by design? > > 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
