1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# each_with_object usage:
('a'..'z').each_with_object({}) do |letter, ascii_table|
@ascii_number ||= 97
ascii_table[letter] = @ascii_number
@ascii_number += 1
end
# tap + each usage:
{}.tap do |ascii_table|
# Making this example, I realize that
# I get this area to initialze things,
# thats is cool!!
@ascii_number = 97
('a'..'z').each do |letter|
ascii_table[letter] = @ascii_number
@ascii_number += 1
end
end