るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

検索結果

<< 1 2 > >>

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

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

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

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

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

@raise Argumen...
...tError 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...

Rinda::TupleSpaceProxy#take(tuple, sec = nil) -> Array | Hash (18237.0)

tuple にマッチするタプルをタプルスペースから取り出して返します。

...::TupleSpace#take にフォワードされます。
詳細は Rinda::TupleSpace#take を参照してください。

@param tuple タプルのパターン
@param sec タイムアウト秒数
@raise Rinda::RequestExpiredError take がタイムアウトした場合に発生します
@raise Ridna::Requ...
...estCanceledError take が何らかの理由でキャンセルされた場合に発生します。...

Rinda::TupleSpace#take(tuple, sec = nil) -> Array | Hash (18231.0)

tuple にマッチするタプルをタプルスペースから取り出して返します。

...時には take をあきらめ
例外 Rinda::RequestExpiredError を発生させます。
sec に nil を指定するとタイムアウトせずに無限に待ち続けます。

@param tuple タプルのパターン
@param sec タイムアウト秒数
@raise Rinda::RequestExpiredError take がタ...
...イムアウトした場合に発生します
@raise Ridna::RequestCanceledError take が何らかの理由でキャンセルされた場合に発生します。...

NEWS for Ruby 2.7.0 (372.0)

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

...は参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.6.0 以降の変更

=== 言語仕様の変更

==== パターンマッチ

* パターンマ...
...出ます。
この警告は「-W:no-deprecated」オプションで止められます。

* ヒアドキュメントの識別子の引用符は同じ行で閉じる必要があります。

//emlist{
<<"EOS
" # This had been warned since 2.4; Now it raises a SyntaxError
EOS
//}

* フリッ...
...numerator::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のように
resumeして、さらに例外を発...

NEWS for Ruby 3.0.0 (324.0)

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

...mlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}

* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in...
...emlist{
0 => a
p a #=> 0

{b: 0, c: 1} => {b:}
p b #=> 0
//}

//emlist{
# version 3.0
0 in 1 #=> false

# version 2.7
0 in 1 #=> raise NoMatchingPatternError
//}

* Find-pattern is added. [EXPERIMENTAL]
16828

//emlist{
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre, String => x, Strin...
...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). Additionally, accessing a
class variab...

絞り込み条件を変える

Enumerator.produce(initial = nil) { |prev| ... } -> Enumerator (112.0)

与えられたブロックを呼び出し続ける、停止しない Enumerator を返します。 ブロックの戻り値が、次にブロックを呼び出す時に引数として渡されます。 initial 引数が渡された場合、最初にブロックを呼び出す時にそれがブロック 呼び出しの引数として渡されます。initial が渡されなかった場合は nil が 渡されます。

...uce { rand(10) }

# ツリー構造の祖先ノードを列挙する Enumerator
ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration }
enclosing_section = ancestors.find { |n| n.type == :section }
//}

このメソッドは Enumerable の各メソッドと組み合...
...うことで、
while や until ループのような処理を実装できます。
例えば Enumerable#detect, Enumerable#slice_after, Enumerable#take_while
などと合わせて使えるでしょう。

//emlist[Enumerable のメソッドと組み合わせる例][ruby]{
# 次の火曜日を返す...
..."date"
Enumerator.produce(Date.today, &:succ).detect(&:tuesday?)

# シンプルなレキサーの例
require "strscan"
scanner = StringScanner.new("7+38/6")
PATTERN = %r{\d+|[-/+*]}
Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
# => ["7", "+", "38", "/", "6"]
//}...

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

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

...zy を返します。

@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 (112.0)

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

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

Enumerator::Lazy#filter {|item| ... } -> Enumerator::Lazy (112.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...

Enumerator::Lazy#filter_map {|item| ... } -> Enumerator::Lazy (112.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 (112.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...

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

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

...zy を返します。

@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...
<< 1 2 > >>