53件ヒット
[1-53件を表示]
(0.169秒)
クラス
- Method (31)
- Proc (11)
- UnboundMethod (11)
検索結果
先頭5件
-
Method
# arity -> Integer (29263.0) -
メソッドが受け付ける引数の数を返します。
...。
//emlist[例][ruby]{
class C
def u; end
def v(a); end
def w(*a); end
def x(a, b); end
def y(a, b, *c); end
def z(a, b, *c, &d); end
end
c = C.new
p c.method(:u).arity #=> 0
p c.method(:v).arity #=> 1
p c.method(:w).arity #=......> -1
p c.method(:x).arity #=> 2
p c.method(:y).arity #=> -3
p c.method(:z).arity #=> -3
s = "xyz"
s.method(:size).arity #=> 0
s.method(:replace).arity #=> 1
s.method(:squeeze).arity #=> -1
s.method(:count).arity #=> -1
//}... -
UnboundMethod
# arity -> Integer (29263.0) -
メソッドが受け付ける引数の数を返します。
...。
//emlist[例][ruby]{
class C
def one; end
def two(a); end
def three(*a); end
def four(a, b); end
def five(a, b, *c); end
def six(a, b, *c, &d); end
end
p C.instance_method(:one).arity #=> 0
p C.instance_method(:two).arity #=> 1
p C.instance_method(:three).arity #=>......nce_method(:four).arity #=> 2
p C.instance_method(:five).arity #=> -3
p C.instance_method(:six).arity #=> -3
String.instance_method(:size).arity #=> 0
String.instance_method(:replace).arity #=> 1
String.instance_method(:squeeze).arity #=> -1
String.instance_method(:count).arity... -
Proc
# arity -> Integer (26251.0) -
Proc オブジェクトが受け付ける引数の数を返します。
...//emlist[例][ruby]{
lambda{ }.arity # => 0
lambda{|| }.arity # => 0
lambda{|x| }.arity # => 1
lambda{|*x| }.arity # => -1
lambda{|x, y| }.arity # => 2
lambda{|x, *y| }.arity # => -2
lambda{|(x, y)| }.arity # => 1
lambda{|(x, y), z|}.arity... -
Method
# curry(arity) -> Proc (11109.0) -
self を元にカリー化した Proc を返します。
...self を元にカリー化した Proc を返します。
カリー化した Proc はいくつかの引数をとります。十分な数の引数が与
えられると、元の Proc に引数を渡し て実行し、結果を返します。引数
の個数が足りないときは、部分適用し......を返します。
@param arity 引数の個数を指定します。可変長の引数を指定できるメソッドを
カリー化する際には必ず指定する必要があります。
//emlist[例][ruby]{
def foo(a,b,c)
[a, b, c]
end
proc = self.method(:foo).curry
proc2 = p......roc.call(1, 2) #=> #<Proc>
proc2.call(3) #=> [1,2,3]
def vararg(*args)
args
end
proc = self.method(:vararg).curry(4)
proc2 = proc.call(:x) #=> #<Proc>
proc3 = proc2.call(:y, :z) #=> #<Proc>
proc3.call(:a) #=> [:x, :y, :z, :a]
//}
@see Proc#curry... -
Method
# curry -> Proc (11009.0) -
self を元にカリー化した Proc を返します。
...self を元にカリー化した Proc を返します。
カリー化した Proc はいくつかの引数をとります。十分な数の引数が与
えられると、元の Proc に引数を渡し て実行し、結果を返します。引数
の個数が足りないときは、部分適用し......を返します。
@param arity 引数の個数を指定します。可変長の引数を指定できるメソッドを
カリー化する際には必ず指定する必要があります。
//emlist[例][ruby]{
def foo(a,b,c)
[a, b, c]
end
proc = self.method(:foo).curry
proc2 = p......roc.call(1, 2) #=> #<Proc>
proc2.call(3) #=> [1,2,3]
def vararg(*args)
args
end
proc = self.method(:vararg).curry(4)
proc2 = proc.call(:x) #=> #<Proc>
proc3 = proc2.call(:y, :z) #=> #<Proc>
proc3.call(:a) #=> [:x, :y, :z, :a]
//}
@see Proc#curry...