[Ironruby-core] say['love'] = "*love*" fails

Ben Hall ben2004uk at googlemail.com
Sat Jun 21 09:27:08 EDT 2008


Hi Curt,

The same happens in both ir and my own editor.

This is from ir.

>>> $say = "I love Ruby"
=> "I love Ruby"
>>> puts $say
I love Ruby
=> nil
>>> $say['love'] = "*LOVE*"
IronRuby.Libraries:0:in `[]=': can't convert String into Integer (TypeError)
        from :0:in `Initialize##11'

This gives a different error that before - it is just because []= is
missing?  I'll take a look at RubyForge and fill a bug if required
later this afternoon.

Thanks

Ben



On Sat, Jun 21, 2008 at 2:22 PM, Curt Hagenlocher <curth at microsoft.com> wrote:
> Is this from ir.exe or from your hosting code?
>
> It looks like you didn't start entirely over. You need to make every reference global and not just subsequent ones.  That is,
>
> $say = "I love Ruby"
> puts $say
> $say['love'] = "*LOVE*"
> ...etc.
>
> Also, it looks like we happen to be missing that particular overload of String.[]=, so if that's not already in RubyForge, you should file a bug report. :)
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ben Hall
> Sent: Saturday, June 21, 2008 5:58 AM
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] say['love'] = "*love*" fails
>
> Hello,
>
> I just wanted to quickly write some Ruby code to see if my hosting
> worked.  Went onto the main ruby site and copied this block of code:
>
> # Output "I love Ruby"
> say = "I love Ruby"
> puts say
>
> # Output "I *LOVE* RUBY"
> say['love'] = "*love*"
> puts say.upcase
>
> # Output "I *love* Ruby"
> # five times
> 5.times { puts say }
>
> When I tried this it failed:
>>>> say['love'] = "*love*"
> :0:in `Initialize##1': undefined local variable or method `say' for main:Object
> (NoMethodError)
>
> I first thought this might have been because the console doesn't
> support local variables and have some other problems going on. So I
> tried this:
>
>>>> $say['love'] = "*love*"
> :0:in `Initialize##11': undefined local variable or method `[]=' for :NilClass (
> NoMethodError)
>
>
> Why isn't this working?
>
> Thanks
>
> Ben
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>


More information about the Ironruby-core mailing list