From: Vikhyat Korrapati Date: 2012-01-21T18:51:25+09:00 Subject: Re: (Beginner Question) Trying to extract elements from an embeded array Hi, I made a minor change and got it to work. :) http://codepad.org/ybmXU9s3 Do you see the change I made, and do you see why it was needed? Vikhyat Korrapati http://vikhyat.net/ On Saturday 21 January 2012 at 3:10 PM, Dave Elman wrote: > Hiya All, > > I've been learning Ruby for about 2 weeks or so and had a go at putting > together proper bit of code, which I of course can't get working ;) Part > of my practice is to see how if..., while..., collect... and so on work. > > In the code I have a set of embedded arrays with various strings. I then > generate a sequential number (0, 1, 2, etc) and a random number. With > those I index into each array in sequence using the sequence number, and > use the random number to pick a string at random from within them. > > The output should be say "a, B" or "c, A", etc. > > I've been testing this in SciTe and get results of either [nil, nil] or > just "a, b" every time. Running it in Codepad I got [nil, nil] and [98, > 98]. > > How the heck I can get nil, nil I don;t know, I'm guessing I'm getting > int/str mixed up here. > > If anyone has a moment, could you look over the code I pasted at > Codepad. Any guidance on what I'm missing here technically and logically > would be greatly appreciated. > > http://codepad.org/ohuMRrlE > > Regards, > > Dave. > > -- > Posted via http://www.ruby-forum.com/.