Holla Tech - Learn

Hello, Ruby!
 

Let’s create our very first Ruby program, the classic “Hello World” program.
For this, we use the built-in puts method. 

puts “Hello World” 

 

This code will output the text “Hello World” to the screen.

NOTE!
All text values (strings) must be enclosed in single or double quotes.

Hello, Ruby!
 

Another method that can be used to display output to the screen is print.
For example:

print “Hello World” 

 

This code displays the same output as before, except that the puts automatically adds a new line after the output, while print does not.
For example:

 

puts "Hi"
print "there"
print "Ruby"

 

Result: 

 

Hi

thereRuby

 

TASK:
Copy and paste the line of codes into a text editor and play around with the outputs.

BACK NEXT

CLICK ON THE BUTTON BELOW TO GO TO THE RUBY MAIN COURSE PAGE. 

RUBY MAIN COURSE PAGE

 


© License: All Rights Reserved 


CONTACT HOLLA TECH – LEARN SUPPORT