Key Highlights
A quick summary of the core Ruby syntax used in our code examples.
We'll cover the following...
We'll cover the following...
Print out
Variable assignment
Read user input
puts "type 'Hi'" input = gets # => type "Hi" puts input # => "Hi\n" ## normally strip off the new line "\n" input = gets.chomp # => "Hi" ## read an integer print "Enter a number" num = gets.chomp.to_i
Getting input from user and converting it to an integer
Conditional
Two boolean values—true and false