Skip to content

Instantly share code, notes, and snippets.

@brookskindle
Created January 19, 2017 01:40
Show Gist options
  • Save brookskindle/ccc716ec9a4d7eaa43a10c57ac3bdada to your computer and use it in GitHub Desktop.
Save brookskindle/ccc716ec9a4d7eaa43a10c57ac3bdada to your computer and use it in GitHub Desktop.

Pre-class Exercises

What is the difference between the following two lines?

num = 4
num == 4

Given the following code:

num = gets.chomp

if num == 4
  puts "Hooray, four is the best!"
elsif num < 0
  puts "Less than zero"
else
  puts "I'm not familiar with that number..."
end

What will happen if the user enters: -1? How about 4? Or 15?


If x and y are defined as:

x = 4
y = x

Will the following boolean expressions be true or false? Why?

(x == 4) && (y >= x + 1)
(x == 4) || (y >= x + 1)

What does

!true

mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment