るりまサーチ

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

別のキーワード

  1. irb/input-method gets
  2. irb/input-method new
  3. _builtin define_method
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

ライブラリ

キーワード

検索結果

Proc#<<(callable) -> Proc (155.0)

self と引数を合成した Proc を返します。

...成した Proc を返します。

戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。

Proc
#>> とは呼...
...が逆になります。

@param callable ProcMethod、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}

//emlist[call を定義したオブジェクト...
...anner
def self.call(str)
str.scan(/\w+/)
end
end

File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}

@see Method#<<, Method#>>...

Proc#>>(callable) -> Proc (155.0)

self と引数を合成した Proc を返します。

...成した Proc を返します。

戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。

Proc
#<< とは呼...
...が逆になります。

@param callable ProcMethod、もしくは任意の call メソッドを持ったオブジェクト。

//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }

# (3 * 3) + (3 * 3)
p (f >> g).call(3) # => 18
//}

//emlist[call を定義したオブジェクト...
...anner
def self.call(str)
str.scan(/\w+/)
end
end

File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT

pipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@see Method#<<, Method#>>...

Proc#ruby2_keywords -> proc (89.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...
...nother 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.

This should only be used for procs that delegate keywords to another
method
, and...
...2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
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 chan...

Proc#lambda? -> bool (61.0)

手続きオブジェクトの引数の取扱が厳密であるならば true を返します。

...list[例][ruby]{
# lambda で生成した Proc オブジェクトでは true
lambda{}.lambda? # => true
# proc で生成した Proc オブジェクトでは false
proc
{}.lambda? # => false
# Proc.new で生成した Proc オブジェクトでは false
Proc
.new{}.lambda? # => false

# 以下、lam...
...bda?が偽である場合
# 余分な引数を無視する
proc
{|a,b| [a,b]}.call(1,2,3) # => [1,2]
# 足りない引数には nil が渡される
proc
{|a,b| [a,b]}.call(1) # => [1, nil]
# 配列1つだと展開される
proc
{|a,b| [a,b]}.call([1,2]) # => [1,2]
# lambdaの場合これらはすべて...
...true
Proc
.new(&lambda {}).lambda? #=> true

lambda(&proc {}).lambda? #=> false
proc
(&proc {}).lambda? #=> false
Proc
.new(&proc {}).lambda? #=> false

n(&lambda {}) #=> true
n(&proc {}) #=> false
n(&Proc.new {}) #=> false

# Method#to_proc...