On 03/01/07, Krekna Mektek <krekna / gmail.com> wrote:
> Hi,
>
> I'd like to know how I can unroll an array into some instance variables.
>
> like this:
>
> pseudocode:
>
> class Person
>   def initialize
>     @name,@address,@place_of_birth,@whatever = Array
>   end
> end
>
> --* So I can call  *--
>
> person1 = Person.new(personal_data)
>
> personal_data = ['Eric','Meanstreet 3','Buenos Aires','etc']
>
> I hope it's clear what I'd like to know..
>
> Krekna
>
>

You do it exactly as you described

irb(main):001:0> personal_data = ['Eric','Meanstreet 3','Buenos Aires']
=> ["Eric", "Meanstreet 3", "Buenos Aires"]
irb(main):002:0> name,address,place_of_birth = personal_data
=> ["Eric", "Meanstreet 3", "Buenos Aires"]
irb(main):003:0> name
=> "Eric"
irb(main):004:0> address
=> "Meanstreet 3"
irb(main):005:0> place_of_birth
=> "Buenos Aires"
irb(main):006:0>