I'm assuming this is the 0.3 release from Rubyforge, is that correct? In the newest build of IronRuby, @textfield.text.strip and @textfield.text.trim both work. It also appears we have fixed the String creation bug you mention (note that '' is a ClrString and "" is a Ruby String):
[11] > rbd IronRuby 0.3.0.0 on .NET 2.0.50727.4913 Copyright (c) Microsoft Corporation. All rights reserved. >>> require 'temp.dll' => true >>> Foo.bar => 'hello world' >>> r = Foo.bar => 'hello world' >>> r.trim => 'hello world' >>> r.strip => "hello world" >>> s = System::String.new "fubar" => 'fubar' >>> exit C:\temp [12] > gc temp.cs public static class Foo { public static string bar() { return "hello world"; } } C:\temp This build can be built from sources at http://github.com/ironruby/ironruby.git, or we should have a release in the next week or so. JD > -----Original Message----- > From: ironruby-core-boun...@rubyforge.org [mailto:ironruby-core- > boun...@rubyforge.org] On Behalf Of Andrew S. Townley > Sent: Tuesday, April 21, 2009 10:08 AM > To: ironruby-core@rubyforge.org > Subject: [Ironruby-core] WinForms event handling > > Hi, > > I was doing a bit of experimenting with ironruby today to see if it > might be useful for some prototyping work that I'm doing. I noticed > that any of the strings returned from the CLR don't automatically > include the ruby string methods. I would've expected that these would > be mapped directly so that you could call @textfield.text.strip instead > of @textfield.text.trim. > > Probably low on the priority list, but was just curious what the plan > was. Assignment to locally created string references doesn't help > either. I know it's early days yet, but this sort of thing will make > it > difficult for people to remember which API applies where--especially if > CLR strings "escape" a particular method context. > > Interesting things seem to also happen if you try and create a CLR type > directly: > > C:\>ir -v > IronRuby 0.3 0.3.0.0 on .NET 2.0.0.0 > > C:\>iirb > irb(main):001:0> require 'mscorlib' > => true > irb(main):002:0> s = System::String.new "fubar" > TypeError: can't convert String into System::Char* > from (irb):0 > from :0:in `eval' > from workspace.rb:80:in `evaluate' > from context.rb:217:in `evaluate' > from irb.rb:147:in `eval_input' > from irb.rb:253:in `signal_status' > from irb.rb:146:in `eval_input' > from ruby-lex.rb:230:in `each_top_level_statement' > from :0:in `loop' > from ruby-lex.rb:229:in `each_top_level_statement' > from :0:in `catch' > from ruby-lex.rb:227:in `each_top_level_statement' > from irb.rb:102:in `eval_input' > from irb.rb:69:in `start' > from :0:in `catch' > from irb.rb:51:in `start' > from iirb:0irb(main):003:0> > > The only way that I've found to ensure that it's really a Ruby string > is > to do something like this > > s = "" << clrstring > > Has anyone else hit this yet? > > Cheers, > > ast > -- > Andrew S. Townley <a...@atownley.org> > http://atownley.org > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core@rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core