Hello, World!
Ruby is a programming language made for humans. Its creator Yukihiro “Matz” Matsumoto wanted programming to be joyful.
This page works like a notebook: it consists of text and code cells. You can edit every cell and run it with ▶ Run or Shift+Enter. Try it right away:
1 + 1Below the cell you see => 2. The => shows the value of the last line – Ruby does that automatically, no extra command needed.
If you want to explicitly print text, use puts (“put string”):
puts "Chunky Bacon!"The text between the quotes is called a string. puts writes it to the output. By the way: puts itself has the value nil – “nothing” – which is why there is no => line here.
A cell may have as many lines as you like. Ruby runs them from top to bottom: every puts writes a line to the output, and at the end the => shows the value of the last line:
puts "Chunky"
puts "Bacon"
6 * 7Go ahead and change things to see what happens – you can't break anything. The ⚡ Live switch next to ▶ Run even runs the code by itself, a second after you stop typing. And if something turns red: don't panic! Error messages are hints, not punishment – lesson 28 teaches you to read them.
Everything you learn is also on the , short and sweet – open it at the top whenever you like; it links to the official Ruby documentation.
Hello, World! – with puts or simply as the value of the last line.# Your code: