るりまサーチ

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

別のキーワード

  1. _builtin to_proc
  2. _builtin proc
  3. proc curry
  4. httpserver mount_proc
  5. readline completion_proc

検索結果

<< 1 2 > >>

Proc#ruby2_keywords -> proc (21183.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
...ds or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed through the proc to other methods.

This should only be used for procs that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This met...
...before 2.7, check that the proc responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
proc
will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send
(:"do_#{meth}", *args, &b...

Object#send(name, *args) -> object (18186.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...クもそのまま引き渡します。

send
が再定義された場合に備えて別名 __send__ も
用意されており、ライブラリではこちらを使うべきです。また
__send__ は再定義すべきではありません。

send
, __send__ は、メソッドの呼び出し制限...
...ば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。

//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby".send(:sub,/./,"R") #=> "Ruby"


class...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

Object#send(name, *args) { .... } -> object (18186.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...クもそのまま引き渡します。

send
が再定義された場合に備えて別名 __send__ も
用意されており、ライブラリではこちらを使うべきです。また
__send__ は再定義すべきではありません。

send
, __send__ は、メソッドの呼び出し制限...
...ば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。

//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby".send(:sub,/./,"R") #=> "Ruby"


class...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...

MiniTest::Assertions#assert_send(array, message = nil) -> true (6125.0)

引数から、式を取り出して評価した結果が真の場合、検査にパスしたことになります。

...します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。

@raise MiniTest::Assertion 取り出した式が偽を返す場合に発生します。

例:
assert_send([%w[foo bar baz], :include?, 'baz'])...

1.6.8から1.8.0への変更点(まとめ) (288.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...らしい
^^;;)

: ((<Proc/Proc.new>)) [change]
: ((<組み込み関数/lambda>)) [change]
: ((<組み込み関数/proc>)) [change]

以下のように変更されました。((<ruby-dev:20358>))

* Proc.new およびブロック引数で与えられる Proc
引数チェ...
...ックがゆるい。break が例外になる。

Proc
.new {|a,b,c| p [a,b,c]}.call(1,2)
=> -:1: wrong # of arguments (2 for 3) (ArgumentError)
from -:1:in `call'
from -:1
ruby 1.6.8 (2002-12-24) [i586-lin...
...[new]
: ((<UNIXSocket/UNIXSocket.socketpair>)) [new]
: ((<UNIXSocket#recv_io|UNIXSocket/recv_io>)) [new]
: ((<UNIXSocket#send_io|UNIXSocket/send_io>)) [new]

追加

: ((<UNIXServer#listen|UNIXServer/listen>)) [new]
: ((<TCPServer#listen|TCPServer/listen>)) [new]...

絞り込み条件を変える

ruby 1.9 feature (90.0)

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

..._identity?

=== 2006-09-11

: Hash#identical
: Hash#identical?

=== 2006-08-31

: Array#shuffle
: Array#shuffle!

追加

=== 2006-07-26

: __send
: __send!

追加

: invoke_method
: invoke_functional_method

削除

=== 2006-07-21

: Module#attr

オプショナル引数の assignable が...
...

=== 2006-06-11

: __callee__ [new]
: __method__ [new]

((<URL:http://www.dm4lab.to/~usa/ruby/d/200606a.html#id20060610_P1_7>))

: Symbol#to_proc

=== 2006-06-10

* 新機能
: BasicObject が導入されました [new]
: local という visibility および Module#local, Module#local_meth...
...が 1文字の String を返すようになりました

* 多重代入、引数渡し
: 多重代入や yield の何かが変わりました
: Proc#yield が導入されました
: nil.yield が導入されました。no block given (LocalJumpError) という例外を生成します
: 仮...

Method (84.0)

Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。

...の組を封入します。
Proc
オブジェクトと違ってコンテキストを保持しません。

=== Proc との差

Method は取り出しの対象であるメソッドが
なければ作れませんが、Proc は準備なしに作れます。その点から
Proc
は使い捨てに向き...
...、Method は何度も繰り返し生成する
場合に向くと言えます。また内包するコードの大きさという点では
Proc
は小規模、Method は大規模コードに向くと言えます。


既存のメソッドを Method オブジェクト化する。

//emlist[例][ruby]{...
..."baz"
//}

しかし、レシーバを固定させる(Method オブジェクトはレシーバを保持する)必
要がないなら Object#public_sendを使う方法も有用。

//emlist[例][ruby]{
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキー...

NEWS for Ruby 2.6.0 (48.0)

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

...ました。 14250

* Refinements がブロック引数にも反映されるようになりました。 14223

* Refinements が Object#public_send にも反映されるようになりました。 15326

* Refinements が Object#respond_to? にも反映されるようになりました。 1...
...しいキーと値に変換できるようになりました。 15143

* Proc
* 新規メソッド
* 関数合成用に Proc#<< と Proc#>> が追加されました。 6284
* 非互換な変更
* Proc#call が $SAFE を変更しなくなりました。 14250

* Random
*...
...bstractSyntaxTree.parse_file はファイルをパースして AST ノードを返します。 [実験的]
* RubyVM::AbstractSyntaxTree.of は proc やメソッドに対応する AST ノードを返します。 [実験的]

* RubyVM
* 新規メソッド
* RubyVM.resolve_feature_pat...

NEWS for Ruby 3.0.0 (48.0)

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

...ror or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs
accepting a single rest argument and no keywords.
16166

//emlist[][ruby]{
pr = proc{|*a, **kw| [a, kw]}

pr.call([1])...
...arning
# 3.0 => a=>1}, {}]
//}

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

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

* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned....
...be compatible for essentially all usages and avoids blocking when using a scheduler. 16792
* Proc
* Proc#== and Proc#eql? are now defined and will return true for separate Proc instances if the procs were created from the same block. 14267
* Queue / SizedQueue
* Queue#pop, SizedQueue#pu...

Marshal フォーマット (36.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...e => false, false => true, nil => nil}).unpack("x2 a c aa aa aa")
# => ["{", 8, "T", "F", "F", "T", "0", "0"]
//}

==== Hash with default value (not Proc)

'}' で始まるデータ構造になります。

//emlist{
| '}' | 要素数(Fixnum形式) | キーの dump | 値の dump | ... | デフォル...
...}", 6, "i", 15, "i", 25, "i", 0]
//}

==== Hash with default_proc

default_proc が設定されている Hash は dump できません。

//emlist[][ruby]{
h = Hash.new { }
Marshal.dump(h)
# => TypeError (can't dump hash with default proc)
//}

=== Struct

構造体クラスのインスタンスの...
...e_eval { @bar } # => 1
File.open('testfile', 'wb') do |f|
Marshal.dump(Bar, f)
end

# 別プログラム相当にするため remove_const
Object.send :remove_const, :Bar

module Bar
end

p bar = Marshal.load(File.binread('testfile'))
p bar.instance_eval { @bar }
# => nil
//}

//emlist[例 3: ク...

絞り込み条件を変える

RubyVM::InstructionSequence.disasm(body) -> String (36.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== c...
...( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 ( 3)
0015 leave...

RubyVM::InstructionSequence.disassemble(body) -> String (36.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== c...
...( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 ( 3)
0015 leave...
<< 1 2 > >>