Ask HN: What does this ruby snippet print and why?

1 points by jhuckestein ↗ HN

  class Base
    def something
      puts "called something base"
      return {a: 1, b: 2}
    end
  end

  class Extended < Base
    def some_method
      puts "something is {a: 1, b: 2}:"
      puts something.inspect
      if false
        puts "doesn't get executed"
        something = {}
      else
        puts "something is now nil:"
        puts something.inspect
      end
    end
  end

  e = Extended.new
  e.some_method
Edit: formatting

1 comment

[ 0.23 ms ] story [ 8.2 ms ] thread

  something is {a: 1, b: 2}:
  called something base
  {:a=>1, :b=>2}
  something is now nil:
  nil
In the end something is nil (instead of {a:1, b:2}) for me on ruby 1.9.3p194 and 2.0.0-p247. Does anyone know why this happens?