Hey all,
I posted the results of some recent experimenting with IronRuby to my
blog
at: http://faithfulgeek.org/2008/6/17/evil-fun-with-ironruby. My
question
is, how do these things work under the covers? Do .NET types that have
a
Ruby equivalent get treated as the Ruby type or is there an extra layer
that
allows any .NET type to be modified at runtime? It’s totally cool that
any
of this is possible, but I was very surprised that it is.
I left a comment on your blog, but I’ll answer here as well.
IronRuby adds the Ruby Enumerable mixin to IEnumerable objects, which
allows
for CLR lists and collections to act more like Ruby arrays. And the new
methods you add to CLR classes in IronRuby will not be available when
calling them from a non-DLR language like C#.
We wouldn’t be very true to Ruby if we didn’t allow you to “monkey
patch” CLR classes and interfaces. And really, this isn’t all that
different than using extension methods in C#.
All classes in IronRuby have a “RubyClass” object associated with them,
even if the class is being imported from the CLR. It’s this object that
defines and manages the Ruby aspects of the class implementation.
I posted the results of some recent experimenting with IronRuby to my
blog at: http://faithfulgeek.org/2008/6/17/evil-fun-with-ironruby. My
question is, how do these things work under the covers? Do .NET types
that have a Ruby equivalent get treated as the Ruby type or is there an
extra layer that allows any .NET type to be modified at runtime? It’s
totally cool that any of this is possible, but I was very surprised that
it is.
Thanks all!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.