24件ヒット
[1-24件を表示]
(0.137秒)
別のキーワード
ライブラリ
- ビルトイン (24)
キーワード
- arity (12)
-
source
_ location (12)
検索結果
-
Proc
# source _ location -> [String , Integer] | nil (6226.0) -
ソースコードのファイル名と行番号を配列で返します。
... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。
//emlist[例][ruby]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc......{}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}
@see Method#source_location... -
Proc
# arity -> Integer (6214.0) -
Proc オブジェクトが受け付ける引数の数を返します。
...
Proc オブジェクトが受け付ける引数の数を返します。
ただし、可変長引数を受け付ける場合、負の整数
-(必要とされる引数の数 + 1)
を返します。
//emlist[例][ruby]{
lambda{ }.arity # => 0
lambda{|| }.arity # => 0
lambd......a{|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 # => 2
//}...