is it possible to do something like the following in Ruby?
hash = {:person => {:name => 'Bob', :age => 33}}
hash[:person] do |person|
person[:name] = 'Alice'
puts "Here, have a beer #{person[:name]}" if person[:age]> 17
end
What I'm trying to avoid is writing it like
hash[:person][:name] = 'Alice'
puts "Here, have a beer #{hash[:person][:name]}" if hash[:person][:age] > 17
Edit: My first example was a bit unclear maybe. I want to be able to execute some code in the block, not just update the values.