Skip to content

Commit 15a2567

Browse files
committed
[DOC] Doc for StringIO.getc
1 parent 3562c34 commit 15a2567

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

doc/stringio/getc.rdoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Reads and returns the next character from the stream:
2+
3+
strio = StringIO.new('foo')
4+
strio.getc # => "f"
5+
strio.getc # => "o"
6+
strio.getc # => "o"
7+
8+
Returns +nil+ if at end-of-stream:
9+
10+
strio.eof? # => true
11+
strio.getc # => nil
12+
13+
Returns characters, not bytes:
14+
15+
strio = StringIO.new('тест')
16+
strio.getc # => "т"
17+
strio.getc # => "е"
18+
19+
strio = StringIO.new('こんにちは')
20+
strio.getc # => "こ"
21+
strio.getc # => "ん"
22+
23+
Related: StringIO.getbyte.

ext/stringio/stringio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,8 @@ strio_each_byte(VALUE self)
958958
* call-seq:
959959
* getc -> character or nil
960960
*
961-
* Reads and returns the next character from the stream;
962-
* see {Character IO}[rdoc-ref:IO@Character+IO].
961+
* :include: stringio/getc.rdoc
962+
*
963963
*/
964964
static VALUE
965965
strio_getc(VALUE self)

0 commit comments

Comments
 (0)