Wolfpack'08
Wolfpack'08

Reputation: 4128

Remove the newline after variable in `puts()` arguments

When I execute

print("Enter your name: ")
name=gets
puts("\tHello, #{name}.")

, I get:

    Hello, Fohsap
.

How do I move the period (.) up to the first line?

Upvotes: 2

Views: 1688

Answers (1)

waldrumpus
waldrumpus

Reputation: 2590

gets will include the newline character in the returned string. To remove that, you can use gets.chomp.

Upvotes: 8

Related Questions