curious as to how to do so at the click of a button ended the cycle. Аny
infinite loop. Looking for in a search engine, which is not working
examples … the problem is that the program had worked at the time, it
probably makes no infinite loop, or as something else?
Can you rephrase the question in a logical manner, and provide a use
case and example?
My program is written in Ruby in the windows, the program runs in the
console, I need to put it in a loop, but if i use key “q” loop cycle
stops.
loop do
break if … (key command need)
end
The question becomes bad, thanks to google translator.
That depends on whether you’re accepting input via “gets”, or you want
something to simply pick up a keypress of “q”.
Here’s how you could do it with “gets”:
loop do
puts ‘Enter anything other than “q” to loop:’
input = gets.chomp
exit if input == ‘q’
puts ‘Looping…’
end
input = gets.chomp
this line pauses code
i need as in your example, but without pause, without stop code.
On Aug 9, 2013, at 9:02 AM, Joel P. [email protected] wrote:
input = gets.chomp
exit if input == ‘q’
break would be better than exit here.
On Aug 9, 2013, at 9:48 AM, gotostereo … [email protected] wrote:
input = gets.chomp
this line pauses code
i need as in your example, but without pause, without stop code.–
Posted via http://www.ruby-forum.com/.
Ruby documentation:
Also this.
Kernel.trap(‘INT’) { run = false }
while run
end