summaryrefslogtreecommitdiff
path: root/doc/string/each_char.rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/string/each_char.rdoc')
-rw-r--r--doc/string/each_char.rdoc17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/string/each_char.rdoc b/doc/string/each_char.rdoc
new file mode 100644
index 0000000000..2dd56711d3
--- /dev/null
+++ b/doc/string/each_char.rdoc
@@ -0,0 +1,17 @@
+With a block given, calls the block with each successive character from +self+;
+returns +self+:
+
+ a = []
+ 'hello'.each_char do |char|
+ a.push(char)
+ end
+ a # => ["h", "e", "l", "l", "o"]
+ a = []
+ 'こんにちは'.each_char do |char|
+ a.push(char)
+ end
+ a # => ["こ", "ん", "に", "ち", "は"]
+
+With no block given, returns an enumerator.
+
+Related: see {Iterating}[rdoc-ref:String@Iterating].