Hello World in Ruby

Our first program will print the classic “hello world” message. Here’s the full source code.

puts 'hello world'

To run the program, save the code in a file named hello_world.rb and use the Ruby interpreter to execute it.

$ ruby hello_world.rb
hello world

Sometimes we’ll want to package our programs for easier distribution. In Ruby, this can mean creating a Gem, but for simple scripts, just running the .rb file is common practice.

Now that we can run basic Ruby programs, let’s learn more about the language.

查看推荐产品

Comments powered by Disqus