8件ヒット
[1-8件を表示]
(0.041秒)
ライブラリ
- ビルトイン (8)
キーワード
-
each
_ byte (2) -
each
_ char (2) -
each
_ codepoint (2) -
each
_ line (2)
検索結果
先頭5件
-
String
# each _ byte -> Enumerator (18649.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
String
# each _ codepoint -> Enumerator (18649.0) -
文字列の各コードポイントに対して繰り返します。
...ます。
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}
@see String#codepoints... -
String
# each _ char -> Enumerator (18631.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
String
# each _ line(rs = $ / ) -> Enumerator (18631.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}
@see String#lines... -
String
# each _ byte {|byte| . . . } -> self (18349.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
String
# each _ codepoint {|codepoint| block } -> self (18349.0) -
文字列の各コードポイントに対して繰り返します。
...ます。
//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}
@see String#codepoints... -
String
# each _ char {|cstr| block } -> self (18331.0) -
文字列の各文字に対して繰り返します。
...文字列の各文字に対して繰り返します。
たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界
@see String#chars... -
String
# each _ line(rs = $ / ) {|line| . . . } -> self (18331.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}
@see String#lines...