Using IronRuby from C# is like a one-way street. I can take a C#
object, and use it from the DLR. But I can’t enhance that object and
return it back to C#. When I return it back, it looses all the Ruby
This is by design. System.String doesn’t really have “reverse” method.
IronRuby just pretends it’s there to make work more like Ruby string. So
while you’re writing Ruby code you use these convenience methods, but
once you’re in another context (another language, be it C#, or Python)
you won’t see them.
Using SimpleDelegator I can send back a delegate to Ruby’s string and
access the reverse method.
Unfortunately, since the reversed string is sent back to the CLR, its a
System::String. So I couldn’t call str.reverse().reverse().
It should be possible to get back a Ruby String (or any other Ruby
object) and use it from C#. Without this, you can not effectively use
IronRuby to enhance a legacy C# project. It is like having a Berlin
Wall between the CLR and DLR. As a visitor you can get into the DLR.
But as a citizen you cant get out of the DLR!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.