Stefano Crocco
8/22/2007 10:57:00 AM
Alle mercoledì 22 agosto 2007, Akif Tokuz ha scritto:
> Hi
> i am a beginner Rubyist and I have a small problem.
>
>
> Track=Struct.new(:name,:surname)
>
> #This works perfectly
> tempTrack=Track.new(15,"b")
> p tempTrack.name
> p tempTrack.surname
>
>
> But I want to create a temptrack with an incoming array how can i
> convert
>
> [15,"b"] in to 15,"b"
>
>
> #And of course this doesnt work
> incomingArray=[15,"b"]
> tempTrack=Track.new(incomingArray)
> p tempTrack.name
> p tempTrack.surname
>
> Thanks.
> Akif,
You need to do this:
Track.new(*[15, 'b'])
I hope this helps
Stefano