B
bookie988
the array postcodes should be filled with strings starting looking
like
["AA",AB",AC"..."BA","BB","BC" to "ZZ"] 26*26 entries.
i've come up with the following to create it,
postcodes = Array.new
# create postal codes array
W = String.new()
X = String.new()
(A..Z).each do |W| {
puts W
(A..Z).each do |X| {
postcodes.push("#{W}#{X}")
}
}
puts(postcodes)
this code produces
hpricot-test.rb:20: syntax error, unexpected tCONSTANT, expecting kDO
or '{' or '('
hpricot-test.rb:22: odd number list for Hash
hpricot-test.rb:25: syntax error, unexpected '}', expecting kEND
hpricot-test.rb:57: syntax error, unexpected $end, expecting kEND
what am i doing wrong, is there an easier (rubier) way?
like
["AA",AB",AC"..."BA","BB","BC" to "ZZ"] 26*26 entries.
i've come up with the following to create it,
postcodes = Array.new
# create postal codes array
W = String.new()
X = String.new()
(A..Z).each do |W| {
puts W
(A..Z).each do |X| {
postcodes.push("#{W}#{X}")
}
}
puts(postcodes)
this code produces
hpricot-test.rb:20: syntax error, unexpected tCONSTANT, expecting kDO
or '{' or '('
hpricot-test.rb:22: odd number list for Hash
hpricot-test.rb:25: syntax error, unexpected '}', expecting kEND
hpricot-test.rb:57: syntax error, unexpected $end, expecting kEND
what am i doing wrong, is there an easier (rubier) way?