+ 2
Ruby input in loops
hello, I am trying to write a stupid little game in ruby that picks two random numbers and the user must give the product of those two numbers. I want the playground to ask for three different products, so I am using a while loop. but the playground only asks for input once, and then for the second two loops it just puts the input at zero. anyone know how to fix this? I want the playground to ask for input for each iteration.
4 Réponses
+ 12
All input has to be fed to the compiler/interpreter prior to code compilation/interpretation. Loops and user input does not work well on Code Playground. You may have to alter the structure of your code to receive all input outside the loop. Split multiple input into different lines. E.g.
49
25
39
+ 8
@Ace Yes, I believe it has always been this way.
+ 3
Ok that helps thanks!
+ 2
sweet thanks!