- What do we mean when we talk about a variable's "scope"?
- Given the following code, what does the program output?
def combine_variables(x)
puts "inner x is: #{x}"
puts "and outer b is: #{b}"
end
def b
12
end
a = 4
combine_variables(a)
- What is the value of
hero
after this code has executed?
new_creatures = ["IntrepidDecomposedCyclist", "Dragon"]
villain = "AssistantViceTentacleAndOmbudsman"
hero = "who knows"
new_creatures.each do |villain|
hero = "Dwemthy"
puts "this time the villain is #{villain} and the hero is #{hero}"
end
-
What is a "handle" in terms of File I/O?
-
What is the difference between "w", "r", and "a" modes in File I/O?
-
Imagine we're writing software to model a Corgi dog. You don't need to write the implementation, but write a test for each of the following features:
-
A Corgi has a name.
-
A Corgi has an age.
-
A Corgi can lie down.
-
A Corgi can stand up.
-
A Corgi cannot lie down when already lying down.
-
A Corgi cannot stand when it is already standing.
-
A Corgi starts hungry.
-
A Corgi can eat, but only when it is hungry.
-
A Corgi is no longer hungry when it has eaten three times.