Any way to peek at the first character of $stdin without actually
consuming it?
I tried using #rewind but get a seek error.
Thanks.
Any way to peek at the first character of $stdin without actually
consuming it?
I tried using #rewind but get a seek error.
Thanks.
On Mon, Dec 27, 2010 at 8:12 PM, Intransition [email protected]
wrote:
Any way to peek at the first character of $stdin without actually
consuming it?
What about IO#getc and IO#ungetc.
Regards,
Ammar
On Dec 27, 11:06am, Ammar A. [email protected] wrote:
On Mon, Dec 27, 2010 at 8:12 PM, Intransition [email protected] wrote:
Any way to peek at the first character of $stdin without actually
consuming it?
I assume you don’t want to look at the first char as soon as it’s
typed
What about IO#getc and IO#ungetc.
On versions < 1.9 these will only read bytes, regardless of $KCODE.
What’s a reasonable alternative, $stdin.readline.chars.to_a[0] ?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs