るりまサーチ

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.005秒)
トップページ > クラス:Object[x] > クエリ:tap[x]

ライブラリ

検索結果

Object#tap {|x| ... } -> self (18126)

self を引数としてブロックを評価し、self を返します。

...的です。

(1..10) .tap {|x| puts "original: #{x.inspect}"}.
to_a .tap {|x| puts "array: #{x.inspect}"}.
select {|x| x % 2 == 0} .tap {|x| puts "evens: #{x.inspect}"}.
map { |x| x * x } .tap {|x| puts "squares: #{x.inspect}"}...