お世話になります
下記の繰り返しeachのコードをtimesに置き換えることはできますか?
{cat:200, dog:400}.each do |name, score| puts "#{name}: #{score}" end
{cat:200, dog:400}.times { |name, score| puts "#{name}: #{score}" }
こう記述するとエラーになります
Traceback (most recent call last):
hello.rb:1:in <main>': undefined method
times' for {:taguchi=>200, :fkoji=>400}:Hash (NoMethodError)
原因と理由をご教授ください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/01 06:19
2019/04/01 06:21
2019/04/01 06:22
2019/04/01 06:26
2019/04/01 06:30 編集
2019/04/01 09:31