私はChrisPineのRubyの本を読んでいますが、コードがうまく機能しない理由が少しわかりません。
birthdays.txt
次のような約10行のテキストを含むというファイルがあります。
Andy Rogers, 1987, 02, 03
等
私のコードは次のとおりです。
hash = {}
File.open('birthdays.txt', "r+").each_line do |line|
name, date = line.chomp.split( /, */, 2 )
hash[name] = date
end
puts 'whose birthday would you like to know?'
name = gets.chomp
puts hash[name]
puts Time.local(hash[name])
私の質問は、なぜコードの最後の行がTime.local(hash[name])
この出力を生成するのですか?:
1987-01-01 00:00:00 +0000
それ以外の:
1987-02-03 00:00:00 +0000