Method: StringIO#each_char

Defined in:
ext/stringio/stringio.c

#each_char {|c| ... } ⇒ self

With a block given, calls the block with each remaining character in the stream; see Character IO.

With no block given, returns an enumerator.

Yields:

  • (c)

Returns:

  • (self)


1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
# File 'ext/stringio/stringio.c', line 1062

static VALUE
strio_each_char(VALUE self)
{
    VALUE c;

    RETURN_ENUMERATOR(self, 0, 0);

    while (!NIL_P(c = strio_getc(self))) {
  rb_yield(c);
    }
    return self;
}