Forum: IronRuby C# method returns string to IronRuby - how it automatically be a IronRuby string?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D4ced0fe3718f187173fc05dd7f33f57?d=identicon&s=25 Ben Hall (Guest)
on 2009-04-16 18:16
(Received via mailing list)
Hello,

Just hosted the DLR within an application to allow users some
scripting functionality.  Part of the functionality is that you can
call a C# method and have a string returned. However, the string is
always being returned as a ClrString which means methods like << don't
work which is annoying.  Having to write to_s after every call isn't
great for my nice clean DSL :)

How can I get around this? I want my C# method to return Ruby string.

Thanks

Ben
1e39a948a58f4569c53d971c2e120920?d=identicon&s=25 Ivan Porto carrero (casualjim)
on 2009-04-16 19:02
(Received via mailing list)
Monkey patch ClrString with the methods you need?
Or make your C# method return MutableString if you are able to
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-04-16 19:34
(Received via mailing list)
Do you have the latest build of IronRuby?
Non-mutable Ruby methods are implemented there on CLR strings.

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Thursday, April 16, 2009 9:12 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] C# method returns string to IronRuby - how
it automatically be a IronRuby string?

Monkey patch ClrString with the methods you need?
Or make your C# method return MutableString if you are able to
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

On Thu, Apr 16, 2009 at 5:59 PM, Ben Hall
<ben2004uk@googlemail.com<mailto:ben2004uk@googlemail.com>> wrote:
Hello,

Just hosted the DLR within an application to allow users some
scripting functionality.  Part of the functionality is that you can
call a C# method and have a string returned. However, the string is
always being returned as a ClrString which means methods like << don't
work which is annoying.  Having to write to_s after every call isn't
great for my nice clean DSL :)

How can I get around this? I want my C# method to return Ruby string.

Thanks

Ben
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
D4ced0fe3718f187173fc05dd7f33f57?d=identicon&s=25 Ben Hall (Guest)
on 2009-04-16 22:55
(Received via mailing list)
I am using 0.3 build but I can grab the latest tomorrow. If that fails
I will give MutableString strings a try - thanks for the responses :)

On Thu, Apr 16, 2009 at 6:27 PM, Tomas Matousek
This topic is locked and can not be replied to.