public
Created

tapを使ってメソッドチェインの途中の値をログ出力する ref: http://qiita.com/items/c94f57047560deea09ba

  • Download Gist
development.log
1
TEST
file0.rb
Ruby
1 2
"Test".upcase.reverse.next.swapcase
# => "tseu"
file1.rb
Ruby
1 2 3 4 5
"Test".upcase.tap{|s| p s }.reverse.tap{|s| p s }.next.tap{|s| p s }.swapcase
"TEST"
"TSET"
"TSEU"
# => "tseu"
file2.rb
Ruby
1 2
"Test".upcase.tap{|s| Rails.logger.debug s }.reverse.next.swapcase
# => "tseu"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.