What do you think the only possible order of execution would be? It's not
difficult to look at that and figure out exactly which section is executed
first

Also - if you are going to test something - at least print out the variable
in question AFTER you increment it - it makes your "debugging output" look
rather much less helpful to you.

Maybe if you got this it would make more sense to you

2hi
3hi
4hi
5"good"

??

http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html -
look at the "if and unless modifiers" section.

There is also the notion that there is ZERO reason for you to need to write
something more complex then necessary when learning something.

This works just as fine and you would understand it.

n = 1
loop do
  n = n + 1
  print "#{n}"
  if n < 5
    puts 'hi'
    next
  end
  p 'good'
  break
end

You are continually trying to add 20 different unknown concepts into your
thought stream - take things one at a time - learn them well - then start
mixing and matching concepts to see how it comes together.

John

BTW - even if the parser takes the next puts 'hi' unless n == 5 concept -
that's really just not code that is used by anyone that I've seen. Again,
mixing too many concepts for no gain at all.