Peek at $stdin

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] ?