Um momento
0x00Lesson 1 of 6

Run your first Ruby program

Print a message and meet Ruby’s readable syntax.

13 min 4-question quiz 1 code exercise
By the end of this lesson you can
  • 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.

main.rb
puts "Hello, Ruby!"
puts "Nice to meet you."
Output
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.

Exercise 1

Print a greeting

+25 XP

Print exactly Hello, Ruby! on one line with puts.

  • Greeting
main.rb
Loading editor…

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…

Gostou da aula? 😆👍
Apoie nosso trabalho com uma doação: