Quick test how tap, then methods of ruby lang work.

tap

a = { lang: 'ruby' }
a.object_id
=> 300

b = a.tap{|o| o[:version] = '2.7' }
b
=> {:name=>"ruby", :version=>"2.7"}
b.object_id
=> 300

a
=> {:name=>"ruby", :version=>"2.7"}
a.object_id
=> 300

then

a = { lang: 'ruby' }
a.object_id
=> 320

b = a.then{|o| o[:version] = '2.7'; o }
b
=> {:name=>"ruby", :version=>"2.7"}
b.object_id
=> 320

a
=> {:name=>"ruby", :version=>"2.7"}
a.object_id
=> 320

Recources

https://docs.ruby-lang.org/en/2.7.0/Object.html#method-i-tap