Skip to content
instance method

IO#getc

() -> ::String?
getc → character or nil

Reads and returns the next 1-character string from the stream; returns nil if already at end-of-stream. See Character IO.

Example
f = File.open('t.txt')
f.getc     # => "F"
f.close
f = File.open('t.rus')
f.getc.ord # => 1090
f.close

Related: IO#readchar (may raise EOFError).

See also #getbyte #getch #fsync #getpass also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0