前置き - caller()
検証スクリプト。
def hoge yield end def piyo puts caller end puts "RUBY_VERSION: #{RUBY_VERSION}" hoge{ piyo }
そして実行結果。
RUBY_VERSION: 1.8.7 hoge.rb:10 hoge.rb:2:in `hoge' hoge.rb:10
RUBY_VERSION: 1.9.1 hoge.rb:10:in `block in <main>' hoge.rb:2:in `hoge' hoge.rb:10:in `<main>'
caller()のフォーマットが変わっている。これは、必ず
ファイル名:行番号:in `呼び出し元'
と正規化されていると考えていいのだろうか。
統一性があるようになったのはいいことだと思う。