るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

Enumerable#detect(ifnone = nil) -> Enumerator (18208.0)

要素に対してブロックを評価した値が真になった最初の要素を返します。

...初の 3 の倍数を探す
p [1, 2, 3, 4, 5].find {|i| i % 3 == 0 } # => 3
p [2, 2, 2, 2, 2].find {|i| i % 3 == 0 } # => nil

# ifnone の使用例
ifnone = proc { raise ArgumentError, "item not found" }
p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
# ArgumentError: item not found
//}...

Enumerable#detect(ifnone = nil) {|item| ... } -> object (18208.0)

要素に対してブロックを評価した値が真になった最初の要素を返します。

...初の 3 の倍数を探す
p [1, 2, 3, 4, 5].find {|i| i % 3 == 0 } # => 3
p [2, 2, 2, 2, 2].find {|i| i % 3 == 0 } # => nil

# ifnone の使用例
ifnone = proc { raise ArgumentError, "item not found" }
p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
# ArgumentError: item not found
//}...

Enumerable#find(ifnone = nil) -> Enumerator (3108.0)

要素に対してブロックを評価した値が真になった最初の要素を返します。

...初の 3 の倍数を探す
p [1, 2, 3, 4, 5].find {|i| i % 3 == 0 } # => 3
p [2, 2, 2, 2, 2].find {|i| i % 3 == 0 } # => nil

# ifnone の使用例
ifnone = proc { raise ArgumentError, "item not found" }
p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
# ArgumentError: item not found
//}...

Enumerable#find(ifnone = nil) {|item| ... } -> object (3108.0)

要素に対してブロックを評価した値が真になった最初の要素を返します。

...初の 3 の倍数を探す
p [1, 2, 3, 4, 5].find {|i| i % 3 == 0 } # => 3
p [2, 2, 2, 2, 2].find {|i| i % 3 == 0 } # => nil

# ifnone の使用例
ifnone = proc { raise ArgumentError, "item not found" }
p [1, 2, 3, 4, 5].find(ifnone) {|i| i % 7 == 0 }
# ArgumentError: item not found
//}...

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
//}

* フリッ...
...た。7877

//emlist[Enumerator.produce][ruby]{
require "date"
dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates
dates.detect(&:tuesday?) #=> next Tuesday
//}
//emlist[Enumerator::Lazy#eager][ruby]{
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eag...

絞り込み条件を変える

NEWS for Ruby 2.0.0 (126.0)

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

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

== 1.9.3 以降の変更

=== 言語仕様の変更

* キーワード引数を追加しました...
...IO#wait_readable は IO#wait の別名です。

* json
* 1.7.7 に更新

* net/http
* 新機能
* Proxies are now automatically detected from the http_proxy environment
variable. See Net::HTTP.new for details.
* gzip and deflate compression are now requested for al...
...m

* openssl
* Consistently raise an error when trying to encode nil values. All instances
of OpenSSL::ASN1::Primitive now raise TypeError when calling to_der on an
instance whose value is nil. All instances of OpenSSL::ASN1::Constructive
raise
NoMethodError in the same case....

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

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

...ev.parent or raise StopIteration }
enclosing_section = ancestors.find { |n| n.type == :section }
//}

このメソッドは Enumerable の各メソッドと組み合わせて使うことで、
while や until ループのような処理を実装できます。
例えば Enumerable#detect, Enumerable...
...# 次の火曜日を返す例
require "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? }.firs...