るりまサーチ

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

別のキーワード

  1. _builtin cycle
  2. array cycle
  3. enumerable cycle
  4. pp pretty_print_cycle
  5. object pretty_print_cycle

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Array#cycle(n=nil) -> Enumerator (18120.0)

配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。

...した場合は Enumerator を返します。

@
param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@
raise TypeError 引数に整数以外の(暗...
...黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
//}...

Array#cycle(n=nil) {|obj| block } -> nil (18120.0)

配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。

...した場合は Enumerator を返します。

@
param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@
raise TypeError 引数に整数以外の(暗...
...黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
//}...

Enumerable#cycle(n=nil) -> Enumerator (18120.0)

Enumerable オブジェクトの各要素を n 回 or 無限回(n=nil)繰り返し ブロックを呼びだします。

...[ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c.
//}

ブロックを省略した場合は、n 回 or 無限回 enum の各要素を
繰り返す Enumerator を返します。

@
return ブロックを指定...

Enumerable#cycle(n=nil) {|obj| ... } -> object | nil (18120.0)

Enumerable オブジェクトの各要素を n 回 or 無限回(n=nil)繰り返し ブロックを呼びだします。

...[ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
a.cycle(2) {|x| puts x } # print, a, b, c, a, b, c.
//}

ブロックを省略した場合は、n 回 or 無限回 enum の各要素を
繰り返す Enumerator を返します。

@
return ブロックを指定...

Object#pretty_print_cycle(pp) -> () (6119.0)

プリティプリント時にオブジェクトの循環参照が検出された場合、 Object#pretty_print の代わりに呼ばれるメソッドです。

...の pp の出力をカスタマイズしたい場合は、
このメソッドも再定義する必要があります。

@
param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print_cycle(q)
q.text(empty? ? '[]' : '[...]')
end
end
//}

@
see Object#pretty_print...

絞り込み条件を変える

pp (540.0)

オブジェクトなどを見やすく出力するためのライブラリです。

...10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@
buf=#<PrettyPrint::Group:0x81a0c98 @group=0, @tail=0, @buf=[#<PrettyPrint::Gro
up:0x81a0ba8 @group=1, @tail=0, @buf=[#<PrettyPrint::Text:0x81a0b30 @tail=2, @wi
dth=1, @text="[">, #<PrettyPrint::Group:0x81a0a68 @group=2, @ta...
...il=1, @buf=[#<Pre
ttyPrint::Text:0x81a09f0 @tail=1, @width=1, @text="1">], @singleline_width=1>, #
<PrettyPrint::Text:0x81a0a7c @tail=0, @width=1, @text=",">, #<PrettyPrint::Break
able:0x81a0a2c @group=2, @gensace=#<Proc:0x81a0cc0>, @newline="\n", @indent=1, @
tail=2, @sep=" ", @width=1>, #<...
...,
@
tail=0>,
@
genspace=#<Proc:0x40d0656>,
@
nest=[0],
@
newline="\n",
@
sharing_detection=false,
@
stack=[]>


=== 出力のカスタマイズ

あるクラスの pp の出力をカスタマイズしたい場合は、
そのクラスで pretty_print メソッドと pretty_print_cycle...

Enumerator::Lazy#take_while -> Enumerator::Lazy (24.0)

Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。

...list[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>

1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.forc...
...e.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}

@
see Enumerable#take_while...

Enumerator::Lazy#take_while {|item| ... } -> Enumerator::Lazy (24.0)

Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。

...list[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>

1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.forc...
...e.last(5)
# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}

@
see Enumerable#take_while...

Enumerator::Lazy#zip(*lists) -> Enumerator::Lazy (24.0)

Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。

...uby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>

1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}

@
see Enumerable#zip...
<< 1 2 > >>