Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) Ruby Strings Whitespace

I thought that "puts string" went after the string to make it appear in the console

one of the questions in the ruby basics on strings is that the following line of code would create a string with three lines.

string = "Hello
my name is Jason
and I like ruby"

I thought that in order for the code to show up correctly in the console it had to end with a puts string outside quotation marks.

string = "Hello
my name is Jason
and I like ruby"

puts string

did I just misread the question, or do you not need the <code> puts string</code> at the end of the document?

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

irb is a REPL environment, it, by default, always echoes and printout the value of every expression you enter, with or without the use of puts, that's what REPL is all about.

However, if you put the ruby code into a rb file, and compiles it using ruby file.rb, nothing will be printed on the screen unless the puts statement is used.