fork download
  1. class MathGame
  2. x=0
  3. temp=100
  4. puts temp.to_i # this prints 100
  5.  
  6. for i in 0..100
  7. t=100
  8.  
  9. r = Random.new
  10. r.rand(temp)
  11.  
  12.  
  13. puts "#{x}+ #{r} = ?" #this prints the number in another format
  14. temp = gets
  15. x=x+r
  16. if temp==x
  17. puts " Right!"
  18. else
  19. puts " Wrong!"
  20. end
  21. end # does not loop
  22. end
Runtime error #stdin #stdout #stderr 0.01s 7432KB
stdin
Standard input is empty
stdout
100
0+ #<Random:0x9d875d0> = ?
stderr
prog.rb:15:in `+': Random can't be coerced into Fixnum (TypeError)
	from prog.rb:15:in `block in <class:MathGame>'
	from prog.rb:6:in `each'
	from prog.rb:6:in `<class:MathGame>'
	from prog.rb:1:in `<main>'