![]() |
|
|
|
|
1
22nd October 19:08
External User
Posts: 1
|
Why,
The Programming Ruby suggests using *for* for Array. Unfortunately I don't have the book with me. I will tell you the page. And it is logical to use it for array. Cheers, Henry -- Posted via http://www.ruby-forum.com/. |
|
|
|
|
2
22nd October 19:10
External User
Posts: 1
|
Well,
I bring it to your attention because: It mentioned in Programming Ruby, that *for* works with array. They gave the example of song array. All languages, which I am familiar with work the same way. They - take an item from Array, - execute the block, - and then take another item So as [0 ... len] is a new Array, I expected the same behaviour. But it was not so obvious. It took the whole array and executes the statement ones. I would expect this behaviour if the code were for i = [0 ... len] So, my question was to persons, who realy UNDERSTAND Ruby internal logic, what was it, a bug or undocumented (or may be documented, but I just missed it) feature? Regards, Henry -- Posted via http://www.ruby-forum.com/. |
|
|
4
22nd October 19:10
External User
Posts: 1
|
[0...len] is Array. Which holds only one Range object:
=> [1...5] => Array => 1 => Range Regards, Rimantas -- http://rimantas.com/ |
|
|
5
22nd October 19:10
External User
Posts: 1
|
Thank you very much, Logan Capaldo.
That was the open eyes explanation, I wanted to get. The case is closed. -- Posted via http://www.ruby-forum.com/. |
|
|
6
22nd October 19:10
External User
Posts: 1
|
While I was writing, I got another message, thank you, Rimantas
-- Posted via http://www.ruby-forum.com/. |
|