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
1. Open terminal 2. Typeirb
and press [enter] 3. Typeputs "Hello, World!"
and press [enter] - Write a hello world program in a Ruby file and execute it from the terminal
1. Open terminal
2. Type
touch hello_world.rb
to create the file 3. Typeatom .
to open the file in Atom 4. Typeputs "Hello, World"
and save the file 5. In terminal typeruby 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 betweenprint
andputs
methods in Ruby.