Chris Moline <ugly-daemon / home.com> writes:

> Ah. Well to be honest that kinda sucks :). I was trying to write a
> method to print out pascal's triangle and kept getting error:
> undefined method []= for nil until I finally remembered we have to
> assign to [] first. grrr :)

I don't know if it helps, but the Perl idiom ||= works in Ruby too:

   fred[i] ||= []

assigns an empty array to fred[i] if fred[i] isn't already initialized.



Dave