JumpStart: Lesson 8
- Write and execute Ruby code
- Practice using
irb
and running Ruby files from the terminal
A Hello World program is the first program that people often write when exploring with a new programming language. In this lesson you will write a hello world program in irb
and using a Ruby file. irb
is great for quick exploration, and using a Ruby file is great when you want to have a record of the code that was written so it can be executed again later.
- Read about the history of "hello, world"
- Write and execute a hello world program in the terminal using
irb
- Open terminal
- Type
irb
and press [enter] - Type
puts "Hello, World!"
and press [enter]
- Open terminal
- Type
touch hello_world.rb
to create the file - Type
code .
to open the file in VS Code - Type
puts "Hello, World"
and save the file - In terminal type
ruby hello_world.rb
and press [enter]
Reflect on the steps you completed, and try them a few more times without referencing the instructions to practice using irb
and from researching online, understand the difference between print
and puts
methods in Ruby.