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 [email protected]
http://atownley.org