From: Luigi Ballabio Date: 2001-05-07T16:21:46+09:00 Subject: [ruby-talk:14755] Re: ranges Hi, At 10:07 AM 5/5/01 +0900, Guy N. Hurst wrote: >Joseph McDonald wrote: > > > > Hi, > > > > Is there a way to construct an array out of a range such > > as: (0..9,"A".."Z","-") ? > > > > This works, but I'm sure it's hokey: > > > > arr = Array.new > > (0..9).to_a.each do |a| > > arr << a > > end > > ("A".."Z").to_a.each do |a| > > arr << a > > end > > arr << "-" > > > >Try: > >arr = (0..9).to_a + ('A'..'Z').to_a + ['-'] > >OR this: > >def foo(*args) > arr = [] > args.each{|x| arr += x.to_a } > arr >end > >arr = foo(0..9,'A'..'Z','-') Nope. If you look at Joseph's code, you'll see the result he meant was ('0A-','0B-',...,''0Z-','1A-',....) Bye, Luigi