From: Robert Klemme Date: 2006-03-23T00:08:51+09:00 Subject: Re: questions/suggestions from a Ruby newbie dblack@wobblini.net wrote: >> -Is there a way to have multidimentional arrays in Ruby? Ie something >> like variable[3][2]? One could use arrays of arrays but it does not >> look quite as clear when reading the code. > > How about: > > variable[3][2] > > ? :-) As long as both variable and variable[3] respond to "[]", you > should be OK. (They don't even have to be arrays.) Also, it's not too difficult to write a multi dimensional array class. Basically you need to make [] and []= accept multiple arguments. Note also, that there is a Matrix class (for n=2). > That starts to tie the language in knots. For one thing, if can take > a method with a block: > > if x { }; y end > > I think things would start to get much too messy, especially with an > optional "do". I think there's also a scoping issue involved: if and while do not introduce a new scope while blocks do: if something a = 10 else a = 20 end puts a # ok [1].each do b = 30 end puts b # not ok > I would recommend living with these constructs for a while, on their > own terms. I'm reasonably certain that it will cease to feel like > something is missing or wrong. +1 Kind regards robert