Ruby Tips

tap

#tap passes an object it was called on to a block

#without tap
hash = {}
hash[:a] = 'b'
hash
# => {:a=>'b'}

#with tap
{}.tap do |hash|
  hash[:a] = 'b'
end
# => {:a=>'b'}

Ruby Tips - a simple ruby tip generator RubyTips.dev

Refresh the page to generate a new tip. Or just click here

Built by @zayneabraham

RubyTips - A random Ruby tip generator | Product Hunt Embed