# Re: My first feeling of Ruby

**URL:** <https://www.ruby-forum.com/t/re-my-first-feeling-of-ruby/72756>\
**Category:** Ruby\
**Created:** [October 18, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/re-my-first-feeling-of-ruby/72756 "2006-10-18T17:43:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 18, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/re-my-first-feeling-of-ruby/72756/1 "2006-10-18T17:43:32Z")

</div>

From: Florent G. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> Today I’m learning Ruby.

Welcome to Ruby! 🙂

> Why #test doesn’t work for local variables? It would be more  
> logic.

The general form for string interpolation is #{…}, where … can be  
any ruby code. Because it’s so unlikely that you’d ever see #@ inside a  
normal string, that is a special case that has a shortcut for it.

For example, the following string: “Use the String#split method.” might  
be typed by a rubyist as an instruction…it would be unfortunate if  
EVERY use of the # character needed to be escaped to prevent it from  
being intpretted as a variable.

> hastables is using a mix of {} and []. Always using {} or [] (but not  
> both) for hastable would be “errorless”.

I understand your perspective. I personally like that Arrays, and  
Hashes, and (any other class) have a [] method available. (When you  
write my\_hash[“A”] you’re actually calling a method named “[]” and  
passing in a parameter “A” to get a return value.) It’s consistent that  
[] means “get the value with this index/key”.

When you are creating a hash or array from a literal, then you need some  
way to distinguish them. I agree that it might be nice if [1,2,3] made  
an array and [“a”=\>1, “b”=\>2] made a hash. Right now, that’s not how it  
works. (Although in the future, we _might_ see some form of the latter  
for an ordered hash implementation. Just speculation, though, not a  
promise.)

> Hmm why [“A”=\>1 , “B”=\>2] silently produce [{“A”=\>1, “B”=\>2}] ?

I suppose for consistency with the fact that:  
my\_method “a”=\>1, “b”=\>2  
and  
my\_method( “a”=\>1, “b”=\>2 )  
and  
my\_method( { “a”=\>1, “b”=\>2 } )  
all create a hash that is passed as the first parameter to the method.

Or, maybe it’s a side effect of existing parsing rules. (I’m not sure on  
the “why”.)
