Sunday, June 19, 2011

errors errors errors.

I did about two hours of work so far today on my rock paper scissors game. I've defined a few rules, set the computer's initial select, and created a main menu that's used to process things. I also tried creating a global proc... but it looks like ruby doesn't like those semantics.

The idea was to save space. Why rewrite the same 3 lines of code every time the computer doesn't understand your input? So I came up with this:

didnotget = Proc.new do |goback|
puts 'I\'m sorry, I don\'t follow that command. Please try again.'
goback
end

This proc SHOULD come up any time the computer doesn't understand what's happening, and the variable at the end of the proc is used to recall the method the user was just on. This isn't working the way I wanted it to, because instead I get this error:
rpsgame.rb:91:in `initialize': undefined local variable or method `didnotget' for # (NameError)
from rpsgame.rb:122:in `new'
from rpsgame.rb:122

Ah well, I'll figure it out eventually. For now, I'm going to grab a taco from Casa at the Oxbow in Napa, and then get some quick grocery shopping done. I'll figure this out when I get home.

No comments:

Post a Comment