Does nine really end up containing a string like that? I would have expected it to be the number 9.
nine = while 1; break 9; end
puts nine
And yes, it prints "9". irb(main):001:0> nine = while 1 do break 9 end
=> 9
irb(main):002:0> nine.class
=> Integer
irb(main):003:0> puts nine
9
=> nil
puts might be calling .to_s on the variable, which is why you see a string, but the loop does return an integer. 9.to_s
=> "9"I over-edited my comment to fit a narrow screen, breaking the example.