面试题答案
一键面试fruits = ['apple', 'banana', 'cherry']
fruit_hash = {}
fruits.each do |fruit|
fruit_hash[fruit] = fruit.length
end
fruit_hash.each do |key, value|
puts "#{key}: #{value}"
end
fruits = ['apple', 'banana', 'cherry']
fruit_hash = {}
fruits.each do |fruit|
fruit_hash[fruit] = fruit.length
end
fruit_hash.each do |key, value|
puts "#{key}: #{value}"
end