RbRuby · Lesson 1 of 11
Hello, Ruby!
Ruby is famous for developer happiness. Matz (Ruby's creator) has said the language is optimized for programmer joy. Let's find out if he was lying.
In Ruby, you use `puts` (put string) to print to the console with a newline, or `print` if you want no newline. Ruby files end in .rb and are run with the ruby command.
◆ Note
Ruby doesn't require semicolons. Parentheses on method calls are usually optional — puts "hello" and puts("hello") are identical. Most Rubyists omit them for single arguments.
Ruby doesn't require semicolons. Parentheses on method calls are usually optional — puts "hello" and puts("hello") are identical. Most Rubyists omit them for single arguments.
✦ Tip
Use `p` instead of `puts` when debugging. `puts` calls `.to_s` on the value (hiding the type), while `p` calls `.inspect`, showing you exactly what the object is — including nil vs empty string, and array brackets.
Use `p` instead of `puts` when debugging. `puts` calls `.to_s` on the value (hiding the type), while `p` calls `.inspect`, showing you exactly what the object is — including nil vs empty string, and array brackets.