るりまサーチ

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

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. matrix det_e
  4. matrix rank_e
  5. open3 capture2e

検索結果

<< 1 2 3 ... > >>

Enumerator::Yielder#yield(*object) -> () (27325.0)

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

...
E
numerator.new で使うメソッドです。

生成された Enumerator オブジェクトの each メソッドを呼ぶと
E
numerator::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の yield メソッドが呼ばれるたびに each に渡された
ブロ...
...ックが yield メソッドに渡された値とともに繰り返されます。

//emlist[例][ruby]{
e
num = Enumerator.new do |y|
y.yield 1, 2, 3
e
nd

e
num.each do |x, y, z|
p [x, y, z]
e
nd
# => [1, 2, 3]
//}...

Fiber.yield(*arg = nil) -> object (24319.0)

現在のファイバーの親にコンテキストを切り替えます。

...Fiber#resume に与えられた引数を yield メソッドは返します。

@param arg 現在のファイバーの親に渡したいオブジェクトを指定します。

@raise FiberError Fiber でのルートファイバーで呼ばれた場合に発生します。


//emlist[例:][ruby]{
a...
...= nil
f = Fiber.new do
a = Fiber.yield()
e
nd

f.resume()
f.resume(:foo)

p a #=> :foo
//}...

Proc#yield(*arg) -> () (18337.0)

手続きオブジェクトを実行してその結果を返します。

...照してください。

「===」は when の所に手続きを渡せるようにするためのものです。

//emlist[例][ruby]{
def sign(n)
case n
when lambda{|n| n > 0} then 1
when lambda{|n| n < 0} then -1
e
lse 0
e
nd
e
nd

p sign(-4) #=> -1
p sign(0) #=> 0
p sign(7) #=> 1
//}...
...sugar もあります。

//emlist[例][ruby]{
fib = lambda{|n|
case n
when 0 then 0
when 1 then 1
e
lse
fib.(n - 2) + fib.(n - 1)
e
nd
}
fib.(10) # => 55
//}



@param arg 手続きオブジェクトに与える引数を指定します。

@raise LocalJumpError Procを生成したメ...

ruby 1.6 feature (16495.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...ruby 1.6 feature
ruby
version 1.6 は安定版です。この版での変更はバグ修正がメイン
になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) ->...
...stable-snapshot

: 2003-01-22: errno

E
AGAIN と EWOULDBLOCK が同じ値のシステムで、EWOULDBLOCK がなくなっ
ていました。現在は、このようなシステムでは、EWOULDBLOCK は、EAGAIN
として定義されています。(これは 1.6.7 とは異なる挙...
...test
e
nd
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
from -:9
ruby
1.6.7 (2002-03-01) [i586-linux]

=> ruby 1.6.6 (2001-12-26) [i586-linux]
5

: 2002-03-03 ((<Marshal/Marshal.load>))

Marshal.load が 1.7 のメソッド Proc#yield...

Object#yield_self -> Enumerator (15462.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...方です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield
_self {|url| URI(url).read }.
yield
_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返しま...
...す。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

絞り込み条件を変える

Object#yield_self {|x| ... } -> object (15462.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...方です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield
_self {|url| URI(url).read }.
yield
_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返しま...
...す。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#yield_self -> Enumerator (12456.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...方です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield
_self {|url| URI(url).read }.
yield
_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返しま...
...す。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#yield_self {|x| ... } -> object (12456.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...方です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield
_self {|url| URI(url).read }.
yield
_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返しま...
...す。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

ruby 1.9 feature (11803.0)

ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。

...ruby 1.9 feature
ruby
version 1.9.0 は開発版です。
以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。
1.9.1 以降は安定版です。
バグ修正がメインになります。

記号について(特に重要なもの...
...* [regexp]: 正規表現の機能拡張
* [marshal]: Marshal ファイルのフォーマット変更
* レベル
* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど(互換性のある変更) (only backward-com...
...ました
#: IO#readchar が 1文字の String を返すようになりました
: IO#ungetc が 1バイトの String を受け付けるになりました
#: ARGF.getc が 1文字の String を返すようになりました

* 多重代入、引数渡し
: 多重代入や yield の何かが変...

NEWS for Ruby 2.7.0 (9921.0)

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

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

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

== 2.6.0 以降の変更

=== 言語仕様の変更

==== パターンマッチ

* パターンマッチが実験的機能として導入されました。 14912

//emlist[][ruby]{
case [0, [1, 2, 3]]
in...
...代入でのrescue修飾子が単一の代入と同じ振る舞いになりました。 8279

//emlist[][ruby]{
a, b = raise rescue [1, 2]
# Previously parsed as: (a, b = raise) rescue [1, 2]
# Now parsed as: a, b = (raise rescue [1, 2])
//}

* 特異クラス構文での yield は警告...

絞り込み条件を変える

NEWS for Ruby 3.0.0 (9519.0)

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

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

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...# and deprecation warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwarding (`...`) now supports leading arguments.
16378

//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
e
nd
//}

* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern match...
...onger shown by default (since Ruby 2.7.2).
Turn them on with `-W:deprecated` (or with `-w` to show other warnings too).
16345
* `$SAFE` and `$KCODE` are now normal global variables with no special behavior.
C-API methods related to `$SAFE` have been removed.
16131 17136
* yield i...

メソッド呼び出し(super・ブロック付き・yield) (9325.0)

メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method

...メソッド呼び出し(super・ブロック付き・yield)
* super
* block
* yield
* block_arg
* numbered_parameters
* call_method

//emlist[例][ruby]{
foo.bar()
foo.bar
bar()
print "hello world\n"
print
Class.new
Class::new
//}

文法:

[式 `.'] 識別子 [`(' [[`*']...
...レシーバが指定されない時は self のメソッドを呼び出しま
す。

`.' と `::' とはほぼ同じ意味です。但し、定数を表す場合は、
`::' を使わなければいけません(例: Math::PI)。逆に、

//emlist[][ruby]{
Klass::Foo
//}

とした場合、常に...
...ます。

//emlist[][ruby]{
def foo
yield
1,2,3
e
nd

foo{|v| p v} #=> 1

def bar
yield
[1,2,3]
e
nd

bar{|a, b, c| p a} #=> 1

def hoge
yield
[1,2,3],4,5
e
nd

hoge{|a, b, c| p a} #=> [1,2,3]
//}


http://www.a-k-r.org/d/2007-08.html#a2007_08_16_1

===[a:numbered_parameters] 番号指定...

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (9312.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
E
numerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...o_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given...
...n.times { yield *val }
e
nd
e
lse
to_enum(:repeat, n)
e
nd
e
nd
e
nd

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat の返り...
<< 1 2 3 ... > >>