るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.125秒)
トップページ > クエリ:i[x] > クエリ:>[x] > クエリ:d[x] > クエリ:arity[x]

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. integer >
  4. float >
  5. module >

ライブラリ

クラス

キーワード

検索結果

Method#arity -> Integer (27367.0)

メソッドが受け付ける引数の数を返します。

...//emlist[例][ruby]{
class C
d
ef u; end
d
ef v(a); end
d
ef w(*a); end
d
ef x(a, b); end
d
ef y(a, b, *c); end
d
ef 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 (27367.0)

メソッドが受け付ける引数の数を返します。

...list[例][ruby]{
class C
d
ef one; end
d
ef two(a); end
d
ef three(*a); end
d
ef four(a, b); end
d
ef five(a, b, *c); end
d
ef 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 #=> -1
p C.i...
...od(: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 #=>...

Method#curry(arity) -> Proc (3325.0)

self を元にカリー化した Proc を返します。

... arity 引数の個数を指定します。可変長の引数を指定できるメソッドを
カリー化する際には必ず指定する必要があります。

//emlist[例][ruby]{
d
ef foo(a,b,c)
[a, b, c]
end

proc = self.method(:foo).curry
proc2 = proc.call(1, 2) #=>...
...#<Proc>
proc2.call(3) #=> [1,2,3]

d
ef 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...

NEWS for Ruby 3.0.0 (30.0)

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

...Keyword arguments are now separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now m...
...vior of Procs
accepting a single rest argument and no keywords.
16166

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

pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]

pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwardi...
...exp literals and all Range objects are frozen. 8948 16377 15504

//emlist[][ruby]{
/foo/.frozen? #=> true
(42...).frozen? # => true
//}

* EXPERIMENTAL: Hash#each consistently yields a 2-element array. 12706
* Now `{ a: 1 }.each(&->(k, v) { })` raises an ArgumentError due to lambda's arity che...