# Say\['love'\] = "\*love\*" fails

**URL:** <https://www.ruby-forum.com/t/say-love-love-fails/141061>\
**Category:** IronRuby\
**Created:** [June 21, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061 "2008-06-21T14:59:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 2:59pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/1 "2008-06-21T14:59:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 3:23pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/2 "2008-06-21T15:23:09Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/3 "2008-06-21T15:32:00Z")

</div>

Yes, you are correct. It tries to match your call to []= with one of  
the existing overloads. There’s no overload for (string, string), so the  
closest one it finds is (object, object) – and the implementation of  
(object, object) is trying to cast the first parameter to an int.

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 3:27pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/4 "2008-06-21T15:27:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/5 "2008-06-21T15:53:07Z")

</div>

I don’t mean to be Clintonesque, but it depends on what the meaning of  
the word “done” is. 🙂 Any number you hear for spec coverage is suspect  
as a measure of done-ness. The specs are still being added to; they’re  
not themselves “done”.

At this point, I don’t think we expect a “1.0 final” release before the  
end of the year.

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 21, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/6 "2008-06-21T15:33:46Z")

</div>

Ahh!! Thank you!

Out of interest, hHow far is the language from being ‘done’? Or is  
that an unknown? Last I heard John mentioned 70% of the specs  
passing?

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 22, 2008, 10:55pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/7 "2008-06-22T22:55:53Z")

</div>

Thanks for the update.

What is the command to run the specs on my local box?

Tried this:  
E:\IronRuby\trunk\>rake spec  
(in E:/IronRuby/trunk)  
2179 examples, 83 failures

rake mspec doesn’t work (as reported previously).

Is that just not available at the moment publicly?

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [June 22, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/say-love-love-fails/141061/8 "2008-06-22T21:05:17Z")

</div>

I would clarify that by saying the core Ruby portions will probably be  
done before the 1.0 final. We also have a lot of work to do on defining  
.NET interop. We’re probably passing about 64% of the core spec’s right  
now, which test the builtin libraries, and about 94% of the language  
specs. The library spec’s are so incomplete that the number doesn’t mean  
anything.

I’ll be working on the coverage runner, so we should be back to daily  
updates on that again.

JD

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] On Behalf Of Curt H.  
[removed\_email\_address@domain.invalid]  
Sent: Saturday, June 21, 2008 6:52 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] say[‘love’] = “_love_” fails

I don’t mean to be Clintonesque, but it depends on what the meaning of  
the word “done” is. 🙂 Any number you hear for spec coverage is suspect  
as a measure of done-ness. The specs are still being added to; they’re  
not themselves “done”.

At this point, I don’t think we expect a “1.0 final” release before the  
end of the year.
