I'm trying to make a math test. I have written this code but console is not being friendly about it. I'm trying to make it print out very impressive and not too slow if the user gets in right in 5 seconds. Here's what I wrote up.
puts "346*3?" begin Timeout::timeout 5 do dans1 = gets.chomp end rescue Timeout::Error dans1 = nil end puts (dans1 || "Too slow!") if dans1 == "1038" puts "Very impressive!" else puts "Better luck next time..." end
Ignore some of the
ends this is only a snippet the rest of my code works fine.