るりまサーチ

最速Rubyリファレンスマニュアル検索!
1603件ヒット [1-100件を表示] (0.142秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. _builtin p
  5. rsa p

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Complex#numerator -> Complex (21214.0)

分子を返します。

...分子を返します。

//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}

@see Complex#denominator...

Array#repeated_permutation(n) -> Enumerator (12302.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...生成する Enumerator オブジェクトを返します。

@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数...
...a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one perm...
...ロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}

@see Array#repeated_combination, Array#permutation...

Enumerator::Yielder#to_proc -> Proc (9207.0)

Enumerator.new で使うメソッドです。

...Enumerator.new で使うメソッドです。

引数を Enumerator::Yielder#yield に渡す Proc を返します。
これは Enumerator::Yielder オブジェクトを他のメソッドにブロック引数と
して直接渡すために使えます。

//emlist[例][ruby]{
text = <<-END
Hello
...
...んにちは
END

enum = Enumerator.new do |y|
text.each_line(&y)
end

enum.each do |line|
p
line
end
# => "Hello\n"
# "こんにちは\n"
//}...

Enumerator::Lazy#compact -> Enumerator::Lazy (9201.0)

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

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

Enumerator::Lazy#drop(n) -> Enumerator::Lazy (9201.0)

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

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

@param n 要素数を指定します。

@raise ArgumentError n に負の数を指定した場合に発生します。

//emlist[例][ruby]{
1.step.lazy.drop(3)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator:...
...1:step>>:drop(3)>

1.step.lazy.drop(3).take(10).force
# => [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
//}

@see Enumerable#drop...

絞り込み条件を変える

Enumerator::Lazy#drop_while {|item| ... } -> Enumerator::Lazy (9201.0)

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

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

//emlist[例][ruby]{
1.step.lazy.drop_while { |i| i < 42 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop_while>

1.step.lazy.drop_while { |i| i < 42 }.take(10).force
# => [42...
..., 43, 44, 45, 46, 47, 48, 49, 50, 51]
//}

@see Enumerable#drop_while...

Enumerator::Lazy#filter_map {|item| ... } -> Enumerator::Lazy (9201.0)

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

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

@raise ArgumentError ブロックを指定しなかった場合に発生します。

//emlist[例][ruby]{
1.step.lazy.filter_map { |n| n * 2 if n.even? }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: (1.step)>:filter_map...
...>

1.step.lazy.filter_map { |n| n * 2 if n.even? }.take(10).force
# => [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]
//}

@see Enumerable#filter_map...

Enumerator::Lazy#grep(pattern) {|item| ... } -> Enumerator::Lazy (9201.0)

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

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

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep(/\A(\d)\1+\z/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep(/\A(\d)\1+\z/)>
(100..Float::INFINITY).lazy.map(&...
...:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep...
...:to_s).grep(/\A(\d)\1+\z/).take(10).force
# => ["111", "222", "333", "444", "555", "666", "777", "888", "999", "1111"]
//}

@see Enumerable#grep, Enumerable#grep_v, Enumerator::Lazy#grep_v...

Enumerator::Lazy#grep_v(pattern) {|item| ... } -> Enumerator::Lazy (9201.0)

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

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

//emlist[例][ruby]{
(100..Float::INFINITY).lazy.map(&:to_s).grep_v(/(\d).*\1/)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: 100..Infinity>:map>:grep_v(/(\d).*\1/)>
(100..Float::INFINITY).lazy.map(&...
...:to_s).grep_v(/(\d).*\1/).take(15).force
# => ["102", "103", "104", "105", "106", "107", "108", "109", "120", "123", "124", "125", "126", "127", "128"]
//}

@see Enumerable#grep_v, Enumerable#grep, Enumerator::Lazy#grep...

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

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

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

ただし一貫性のため、ブロック付きで呼び出した場合は Enumerable#zip
同じ挙動になります。

//emlist[例][ruby]{
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...

絞り込み条件を変える

Enumerator#peek -> object (9143.0)

「次」のオブジェクトを返しますが、列挙状態を変化させません。

...態を変化させません。

Enumerator#next のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり列挙状態を変更しません。

列挙が既に最後へ到達している場合は、StopIteration 例外を発生します...
...e = a.to_enum
p
e.next #=> 1
p
e.peek #=> 2
p
e.peek #=> 2
p
e.peek #=> 2
p
e.next #=> 2
p
e.next #=> 3
p
e.next #raises StopIteration
//}

@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values...

Enumerator#peek_values -> Array (9131.0)

Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。

...Enumerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。

Enumerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり...
...StopIteration 例外を発生します。

このメソッドは Enumerator#next_values と同様
yield

yield nil
を区別するために使えます。

//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
end
e = o.to_enum
p
e.peek_values #=> []
e.next
p
e.peek...
..._values #=> [1]
p
e.peek_values #=> [1]
e.next
p
e.peek_values #=> [1, 2]
e.next
p
e.peek_values # raises StopIteration
//}

@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values...
<< 1 2 3 ... > >>