summaryrefslogtreecommitdiff
path: root/doc/string/each_byte.rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/string/each_byte.rdoc')
-rw-r--r--doc/string/each_byte.rdoc15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/string/each_byte.rdoc b/doc/string/each_byte.rdoc
new file mode 100644
index 0000000000..642d71e84b
--- /dev/null
+++ b/doc/string/each_byte.rdoc
@@ -0,0 +1,15 @@
+With a block given, calls the block with each successive byte from +self+;
+returns +self+:
+
+ a = []
+ 'hello'.each_byte {|byte| a.push(byte) } # Five 1-byte characters.
+ a # => [104, 101, 108, 108, 111]
+ a = []
+ 'こんにちは'.each_byte {|byte| a.push(byte) } # Five 3-byte characters.
+ a # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
+
+With no block given, returns an enumerator.
+
+Related: see {Iterating}[rdoc-ref:String@Iterating].
+
+