w1d3 Revisions Flashcards
0
Q
What does the following code do:
begin Code.parse('str') rescue puts "Error parsing code!" retry end
A
It sets up a condition to catch an exception raised by Code.parse, and tries again.
1
A
Creates a special kid of instance method where #[num] will retrieve the value of pegs[i]
Effectively, it creates the following shorthand:
instance_name[i]
Which stands in for:
instance_name.pegs[i]
2
Q
Explain the following code:
Mastermind::Game.new.play
A
Retrieves the Game class from the Mastermind module, then runs the new method, and then the play method on the object which new returns
3
Q
T/F: begin-rescue-retry-end can be used to respond to a specific type of error.
A
T; the specific error is passed to ‘rescue’