Using ruby, is it possible to easily create an array of each letter in the alphabet and 0-9?
[*('a'..'z'), *('0'..'9')] # doesn't work in Ruby 1.8
or
('a'..'z').to_a + ('0'..'9').to_a # works in 1.8 and 1.9
(0...36).map{ |i| i.to_s 36}
for letters or numbers, you can create ranges and iterate over them. try this to get a general idea:
("a".."z").each { |letter| p letter }
to get an array from it just try the following:
("a".."z").to_a
You can also do it like this:
'a'.upto('z').to_a + 0.upto(9).to_a
Try this:
alphabet_array = [*'a'..'z', *'A'..'Z', *'0'..'9']
Or as a string:
alphabet_string = alphabet_array.join
myarr = [*?a..?z] #generates an array of strings for each letter a to z myarr = [*?a..?z] + [*?0..?9] # array of strings az and 0-9
letters = *('a'..'z')
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
You can simply do this:
("0".."Z").map { |i| i }