class MathGame x=0 temp=100 puts temp.to_i # this prints 100 for i in 0..100 t=100 r = Random.new r.rand(temp) puts "#{x}+ #{r} = ?" #this prints the number in another format temp = gets x=x+r if temp==x puts " Right!" else puts " Wrong!" end end # does not loopend
Standard input is empty
100 0+ #<Random:0x9d875d0> = ?
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>'
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!