るりまサーチ

最速Rubyリファレンスマニュアル検索!
617件ヒット [1-100件を表示] (0.131秒)
トップページ > クエリ:t[x] > クエリ:String[x] > クエリ:Enumerator[x]

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_uintptr_t

ライブラリ

モジュール

オブジェクト

検索結果

<< 1 2 3 ... > >>

Enumerator (44042.0)

each 以外のメソッドにも Enumerable の機能を提供するためのラッパークラスです。 また、外部イテレータとしても使えます。

...義されます。
Enumerator
を介することにより String#each_byte のような
異なる名前のイテレータについても each と同様に Enumerable の機能を利用できます。

Enumerator
を生成するには Enumerator.newあるいは
Object#to_enum, Object#enum_for を利...
...
enumerator
を生成して返します。

=== 注意
外部イテレータとしての機能は Fiber を用いて実装されているため Fiber と同じ制限があります。
例えば以下のようなスレッドをまたいだ呼び出しはエラーになります。

//emlist[例][r...
...uby]{
a = nil
T
hread.new do
a = [1, 2, 3].each
a.next
end.join

p a.next
#=> t.rb:7:in `next': fiber called across threads (FiberError)
# from t.rb:7:in `<main>'
//}...

Enumerator#with_object(obj) -> Enumerator (27243.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

...bj を返す Enumerator を返します。

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
t
o_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

t
o_three_with_string = to_three.with_object("foo")
t
o_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end...
...# => foo:0
# => foo:1
# => foo:2
//}

@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object...

String#each_grapheme_cluster -> Enumerator (27213.0)

文字列の書記素クラスタに対して繰り返します。

...

String
#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#g...
...rapheme_clusters...

String#each_grapheme_cluster {|grapheme_cluster| block } -> self (27213.0)

文字列の書記素クラスタに対して繰り返します。

...

String
#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#g...
...rapheme_clusters...

String#each_byte -> Enumerator (27207.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_byte {|byte| ... } -> self (27207.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 (27207.0)

文字列の各コードポイントに対して繰り返します。

...ントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 124...
...31, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

Enumerator#with_object(obj) {|(*args), memo_obj| ... } -> object (27143.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

...bj を返す Enumerator を返します。

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
t
o_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

t
o_three_with_string = to_three.with_object("foo")
t
o_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end...
...# => foo:0
# => foo:1
# => foo:2
//}

@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object...

String#each_codepoint {|codepoint| block } -> self (27107.0)

文字列の各コードポイントに対して繰り返します。

...ントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 124...
...31, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...
<< 1 2 3 ... > >>