> I've found this useful in situations where I know I'll get a one-element 
> array, and I just want the element, such as an api request that always 
> returns an array even though I asked for a single result, or when I'm not 
> sure I'll get an array or single element

$ irb
irb(main):001:0> a = 1
=> 1
irb(main):002:0> Array(a)
=> [1]
irb(main):003:0> a = [1,2,3]
=> [1, 2, 3]
irb(main):004:0> Array(a)
=> [1, 2, 3]

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to