Complete the code to start the interactive Ruby shell (IRB).
system('[1]')
Typing irb in the terminal starts the interactive Ruby shell where you can try Ruby commands live.
Complete the code to assign the value 10 to variable x inside IRB.
x [1] 10
Use the single equals sign = to assign a value to a variable in Ruby.
Fix the error in the IRB command to print 'Hello World'.
puts [1]Hello World[1]
In Ruby, double quotes " or single quotes ' can be used for strings. Here, double quotes are correct to enclose the string.
Fill both blanks to create a hash with key :name and value 'Alice' in IRB.
person = [1] => [2]
In Ruby, symbols like :name are used as keys in hashes. Strings can be enclosed in single quotes like 'Alice'.
Fill all three blanks to create an array of numbers from 1 to 5 and print each number in IRB.
numbers = ([1]..[2]).to_a numbers.each do |[3]| puts [3] end
The range 1..5 creates numbers from 1 to 5. to_a converts it to an array. The block variable num is used to print each number.