From: Vincent Fourmond Date: 2006-11-19T21:26:15+09:00 Subject: Re: How to put array into variables Luca Scaljery wrote: > Hi All > > I tried to put an array into variables like this > b = "aaa bbb" > s, h = b.scan(/^(\w+)\s(\w+)$/) > > But for some reason 's' becomes an array and 'h' is undefined!! The problem is that scan returns an array of arrays: [ # first match: [ #first group : "aaa", # second group: "bbb" ] ] So you might want in your case: s, h = b.scan(/^(\w+)\s(\w+)$/)[0] s, h = b.scan(/^(\w+)\s(\w+)$/).flatten Vince -- Vincent Fourmond, PhD student http://vincent.fourmond.neuf.fr/