Ask HN: What does this ruby snippet print and why?
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