Consider...

def fred
  yield $k
  puts "in fred #{$k}"
end

$k=2
fred {|o| o = 3}
puts "outside fred #{$k}"

produces:

in fred 2
outside fred 2

why is $k still 2 after the call to fred?

Thanks in advance.