What is the difference between `gets` and `gets.chomp` in Ruby?

What is the difference between gets and gets.chomp in Ruby?

I learned that Ruby gets reads user input and creates a new line, while gets.chomp does the same but removes the newline character. Since gets returns an object, you can call methods on it, like chomp.

Does chomp remove the newline after gets creates it? And is the following order correct when calling gets.chomp?

  1. gets prints a new line
  2. gets returns tmp
  3. tmp.chomp removes the new line
  4. User enters input

Can someone clarify how this works?