B
Ben Thomas
Hi all,
Only just started using ruby so this may be really simple to do, but
here goes:
I'm trying to write a program that asks a user to enter their sex using
"gets" but if the user doesn't type anything for about 5 seconds I want
to print a message, like "Please enter something..." then go back to the
gets prompt. I've tried using the "sleep x" method but it doesn't seem
to work because once gets has been initiated it gets stuck there until
something is entered.
Oh I don't have to use gets, but this is the only method of input I'm
aware of at the moment
Hope this makes sense,
Ben
Only just started using ruby so this may be really simple to do, but
here goes:
I'm trying to write a program that asks a user to enter their sex using
"gets" but if the user doesn't type anything for about 5 seconds I want
to print a message, like "Please enter something..." then go back to the
gets prompt. I've tried using the "sleep x" method but it doesn't seem
to work because once gets has been initiated it gets stuck there until
something is entered.
Oh I don't have to use gets, but this is the only method of input I'm
aware of at the moment
Hope this makes sense,
Ben