Run your first Ruby program
Print a message and meet Ruby’s readable syntax.
- Write a Ruby program that prints a line of text.
Ruby is a general-purpose language designed to make code expressive and readable. A Ruby script can begin with an instruction right away. puts writes a value followed by a newline, and # starts a comment that Ruby ignores.
puts "Hello, Ruby!"
puts "Nice to meet you."Hello, Ruby! Nice to meet you.
Ruby usually does not need semicolons or braces to mark simple statements. The interpreter runs the script from top to bottom, so output appears in the same order as the calls.
Key takeaways
Write a Ruby program that prints a line of text.
Ruby methods and blocks help express operations clearly.
Read each result and error message as feedback about your code.
Lesson quiz
4 questions · pass with 3 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write Ruby
Write Ruby in the editor and run it against sample input. Your code is sent to Wandbox to run.
Print a greeting
Print exactly Hello, Ruby! on one line with puts.
- Greeting
Ruby runs through Wandbox, a free public service. Your source code and test input are sent to that service.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…