On Feb 28, 2007, at 8:10 AM, Jenda Krynicky wrote:

> Logan Capaldo wrote:
>> On Jan 20, 2006, at 3:05 PM, Tom Allison wrote:
>>
>>> my $super_ids;
>>> ...
>>> print $super_id,"\n";
>>
>> In ruby...
>>
>> super_ids = nil # assign to declare
super_ids (plural)
>> ...
>> print super_id, "\n"
super_id (singular)
>>
>> If you run this you'll get
>> NameError: undefined local variable or method `super_id' for  
>> main:Object
>
>
> Which basically means that in this "language" there is NO WAY to  
> declare
> a variable. No way to say, "hey dude, I want a new (censored) x in
> here". All you get is a RUNTIME error if you print (or compute with
> or...) a variable sooner than you assign to it. Which is pretty  
> useless.
> And which means that if I do a
>
> coll.each { |i| blah blah blah}
>
> there is no telling whether it will use a new local i or some i
> "declared" outside. And there is no way to make sure it does one or  
> the
> other.
>
> And whenever I need to loop through something I have to make sure i  
> use
> a different variable than any that could ever be "declared" in the  
> same
> scope. Don't you think it's a bit stupid? You probably don't, you
> program in Ruby.

No, you just need to know if YOU created such a variable within the  
current lexical scope.  Your 'i' in the block will always exist  
INSIDE the block.  In Ruby 1.8, that reuses the 'i' that already  
exists in the current scope, but 1.9/2.0 changes this (I believe;  
haven't personally checked this out).

Of course, if you can't consistently spell your variables the same  
way, the "language" isn't likely to know what you meant.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com