My understanding was that ruby blocks have block scope, and all variables created inside block will live only within the block.
Example case:
food = ['toast', 'cheese', 'wine']
food.each { |food| puts food.capitalize}
puts food
Output:
"Toast"
"Cheese"
"Wine"
"Wine"
If you take the food variable inside the block (Each block), my understanding was that it has block scope. It lives only within the block scope, and does not have any influence on the outer variable food.
But the behavior is different, the outer variable named food is modified in this case. Is this understanding correct, In ruby do we have block scope?