るりまサーチ

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

別のキーワード

  1. _builtin argumenterror
  2. on argumenterror
  3. new argumenterror
  4. dump argumenterror
  5. parse argumenterror

ライブラリ

クラス

キーワード

検索結果

Enumerator::Lazy#take(n) -> Enumerator::Lazy (18147.0)

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

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

n が大きな数 (100000とか) の場合に備えて再定義されています。
配列が必要な場合は Enumerable#first を使って下さい。

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

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

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

1.step.lazy.take(5).force
# => [1, 2, 3, 4, 5]
//}

@see Enumerable#take...

NEWS for Ruby 2.7.0 (36.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...ド引数付きで呼び出すとArgumentErrorになります。 14183

//emlist[][ruby]{
def foo(h, **nil); end; foo(key: 1) # ArgumentError
def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError
def foo(h, **nil); end; foo("str" => 1) # ArgumentError
def foo(h, **nil); end; foo({key: 1}...
...するようになりました。

//emlist[][ruby]{
def bar
lambda
end
bar { puts "Hello" } #=> tried to create Proc object without a block (ArgumentError)
//}

==== その他の変更

* 始端なしRangeが実験的に導入されました。
caseやComparable#clampや定数やDSLなど...
...#=> ["FOO!?", "BAR!?", "BAZ!?"]
//}
//emlist[Enumerator::Lazy#with_index][ruby]{
("a"..).lazy.with_index(1) { |it, index| puts "#{index}:#{it}" }.take(3).force
# => 1:a
# 2:b
# 3:c
//}

* Fiber
* 新規メソッド
* Fiber#raiseメソッドが追加され、Fiber#resumeのよう...

NEWS for Ruby 3.0.0 (36.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...eyword arguments are now separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now mat...
...ning. yield in a class definition outside of a method
is now a SyntaxError instead of a LocalJumpError. 15575
* When a class variable is overtaken by the same definition in an
ancestor class/module, a RuntimeError is now raised (previously,
it only issued a warning in verbose mode)....
...ray#slice / Array#[]
* Array#take
* Array#take_while
* Array#uniq
* Array#*
* Can be sliced with Enumerator::ArithmeticSequence

//emlist[][ruby]{
dirty_data = ['--', 'data1', '--', 'data2', '--', 'data3']
dirty_data[(1..).step(2)] # take each second element
# => ["data1"...

NEWS for Ruby 3.1.0 (18.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...&)
end
//}

* ピン演算子に式を書けるようになりました。 17411

//emlist{
Prime.each_cons(2).lazy.find_all{_1 in [n, ^(n + 2)]}.take(3).to_a
#=> [[3, 5], [5, 7], [11, 13]]
//}

* ピン演算子がインスタンス変数、クラス変数、グローバル変数をサポート...
...ックを開始するための offset: キーワード引数を渡せるようになりました。 offset が文字列の範囲外の場合、 ArgumentError 例外が発生します。 18254

* Thread
* 新規メソッド
* Thread#native_thread_id が追加されました。 17853

*...
...換されるようになりました。

//emlist[Time.new][ruby]{
Time.new(2021, 12, 25, "+07:30")
#=> invalid value for Integer(): "+07:30" (ArgumentError)
//}

* Ruby 3.0 以前では、予期しない結果の 2021-12-25 07:00:00 が返されました。 2021-12-25 07:30:00 や 2021-12-25...

Enumerator::Lazy#collect {|item| ... } -> Enumerator::Lazy (12.0)

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

...を返します。

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

//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>

1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4,...

絞り込み条件を変える

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

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

...m 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,...

Enumerator::Lazy#filter {|item| ... } -> Enumerator::Lazy (12.0)

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

...します。

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

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

1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6...

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

Enumerable#filter_map と同じですが、配列ではなく 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
# => [...

Enumerator::Lazy#find_all {|item| ... } -> Enumerator::Lazy (12.0)

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

...します。

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

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

1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6...

Enumerator::Lazy#map {|item| ... } -> Enumerator::Lazy (12.0)

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

...を返します。

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

//emlist[例][ruby]{
1.step.lazy.map{ |n| n % 3 == 0 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:map>

1.step.lazy.collect{ |n| n.succ }.take(10).force
# => [2, 3, 4,...

絞り込み条件を変える

Enumerator::Lazy#reject {|item| ... } -> Enumerator::Lazy (12.0)

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

...返します。

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

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

1.step.lazy.reject { |i| i.even? }.take(10).force
# => [1, 3, 5,...

Enumerator::Lazy#select {|item| ... } -> Enumerator::Lazy (12.0)

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

...します。

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

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

1.step.lazy.select { |i| i.even? }.take(10).force
# => [2, 4, 6...