Ad space (banner)
๐Ÿ’ŽRuby Lessons
Lesson 2 / 68

Your First Output (puts)

In this lesson you will learn the basic way to print output in Ruby with puts, and get a feel for what kind of language Ruby is. This is for anyone searching for "Ruby puts how to use" or "Ruby for beginners".

Ruby prints text to the screen with puts. It is known for its simple syntax and for being approachable for beginners. It was created by Yukihiro Matsumoto of Japan, with a design philosophy centred on "programmer happiness".

The sample code is a single line: puts "Hello, Ruby!". There is no class or public static void main scaffolding to write first - you can simply start with the work you actually want to do, and that is Ruby's ease of use.

A common stumbling block for beginners is the difference between puts and print. puts adds a newline automatically while print does not, which is worth remembering. That difference matters a lot once you are printing several lines.

Together with the Ruby on Rails framework it is used worldwide for building web services. It is one of the few programming languages that originated in Japan and became a favourite around the world.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Ruby directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)