2015-06-03から1日間の記事一覧

Ruby でコールスタックを取得する

Ruby でメソッドのコールスタックを取得したい場合 Kernel.#caller メソッドが利用できます。 [コード] def test1 p caller end def test2 test1 end test2 [出力] ["/mnt/sub/ruby/test/caller/main.rb:6:in `test2'", "/mnt/sub/ruby/test/caller/main.rb:…