るりまサーチ

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

別のキーワード

  1. _builtin yield
  2. object yield_self
  3. _builtin yield_self
  4. proc yield
  5. fiber yield

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

Fiber#alive? -> bool (19.0)

ファイバーが「生きている」時、真を返します。

...ume されていない
* ブロック内の評価が終了していない (Fiber.yield が呼ばれていない)

//emlist[例:][ruby]{
fr = Fiber.new{
Fiber.yield
"a"
}

p fr.alive? # => true
fr.resume # Fiber.yieldで戻ってくる
p fr.alive? # => true
fr.resume # ブロック内の評価...

Pathname#each_entry -> Enumerator (17.0)

Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

...Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
require "pathname"

Pathname("/usr/local").each_entry {|f| p f }

# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathna...

Pathname#each_entry {|pathname| ... } -> nil (17.0)

Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

...Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。


//emlist[例][ruby]{
require "pathname"

Pathname("/usr/local").each_entry {|f| p f }

# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathname:etc>
# => #<Pathname:include>
# => #<Pathname:lib>
# => #<Pathna...
...Dir.foreach(self.to_s) {|f| yield Pathname.new(f) } と同じです。

ブロックを省略した場合は Enumerator を返します。

//emlist[例][ruby]{
require "pathname"

Pathname("/usr/local").each_entry {|f| p f }

# => #<Pathname:.>
# => #<Pathname:..>
# => #<Pathname:bin>
# => #<Pathna...

Enumerable#each_entry -> Enumerator (13.0)

ブロックを各要素に一度ずつ適用します。

...が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield
1
yield
1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省略した場合は Enumerator が返さ...

Enumerable#each_entry {|obj| block} -> self (13.0)

ブロックを各要素に一度ずつ適用します。

...が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class Foo
include Enumerable
def each
yield
1
yield
1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省略した場合は Enumerator が返さ...

絞り込み条件を変える

Fiber#resume(*arg = nil) -> object (13.0)

自身が表すファイバーへコンテキストを切り替えます。 自身は resume を呼んだファイバーの子となります。

...m arg self が表すファイバーに渡したいオブジェクトを指定します。

@return コンテキストの切り替えの際に Fiber.yield に与えられた引数
を返します。ブロックの終了まで実行した場合はブロックの評価結果
を返し...
...また、Fiber#transfer を呼び出した後に resume を
呼び出した場合に発生します。

//emlist[例:][ruby]{

f = Fiber.new do
Fiber.yield(:hoge)
:fuga
end

p f.resume() #=> :hoge
p f.resume() #=> :fuga
p f.resume() #=> FiberError: dead fiber called
//}...

Thread#[](name) -> object | nil (13.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...:name] = newvalue
yield

ensure
Thread.current[:name] = oldvalue
end
end
//}

この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正しく動作しません。

//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {...

Enumerable#max_by -> Enumerator (7.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

...ng with a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p...

Enumerable#max_by {|item| ... } -> object | nil (7.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

...ng with a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p...

Enumerable#max_by(n) -> Enumerator (7.0)

各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。

...ng with a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (1.0/yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p...

絞り込み条件を変える

<< < 1 2 3 4 5 ... > >>