るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. kernel p
  5. matrix p

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

NoMethodError#args -> [object] (21132.0)

メソッド呼び出しに使われた引数を配列で返します。

...メソッド呼び出しに使われた引数を配列で返します。

例:

begin
foobar(1,2,3)
rescue NoMethodError
p
$!
p
$!.name
p
$!.args
end

# => #<NoMethodError: undefined method `foobar' for main:Object>
:foobar
[1, 2, 3]...

Method#curry -> Proc (9125.0)

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

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

カリー化した Proc はいくつかの引数をとります。十分な数の引数が与
えられると、元の Proc に引数を渡し て実行し、結果を返します。引数
の個数が足りないときは、部分適用したカリー化 Proc を...
...す。

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

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

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

def vararg(*args)
args

end

p
roc = self.method(:vararg).curry(4)
p
roc2 = proc.call(:x) #=> #<Proc>
p
roc3 = proc2.call(:y, :z) #=> #<Proc>
p
roc3.call(:a) #=> [:x, :y, :z, :a]
//}

@see Proc#curry...

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

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

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

カリー化した Proc はいくつかの引数をとります。十分な数の引数が与
えられると、元の Proc に引数を渡し て実行し、結果を返します。引数
の個数が足りないときは、部分適用したカリー化 Proc を...
...す。

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

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

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

def vararg(*args)
args

end

p
roc = self.method(:vararg).curry(4)
p
roc2 = proc.call(:x) #=> #<Proc>
p
roc3 = proc2.call(:y, :z) #=> #<Proc>
p
roc3.call(:a) #=> [:x, :y, :z, :a]
//}

@see Proc#curry...

BasicObject#method_missing(name, *args) -> object (6227.0)

呼びだされたメソッドが定義されていなかった時、Rubyインタプリタがこのメソッド を呼び出します。

...ォルトではこのメソッドは例外 NoMethodError を発生させます。


@param name 未定義メソッドの名前(シンボル)です。
@param args 未定義メソッドに渡された引数です。
@return ユーザー定義の method_missing メソッドの返り値が未定義...
...= data
end
def method_missing(name, lang)
if name.to_s =~ /\Afind_(\d+)_in\z/
if @data[lang]
p
@data[lang][$1.to_i]
else
raise "#{lang} unknown"
end
else
super
end
end
end

dic = Foo.new({:English => %w(zero one two), :Esperanto => %w(nulo u...
...speranto #=> "du"
//}

[注意] このメソッドを override する場合は対象のメソッド名に対して
Object#respond_to? が真を返すようにしてください。
そのためには、Object#respond_to_missing? も同様に override する必
要があります。

@see Object#respo...

WIN32OLE#_getproperty(dispid, args, types) -> object (6214.0)

DISPIDとパラメータの型を指定してオブジェクトのプロパティを参照します。

...DISPIDとパラメータの型を指定してオブジェクトのプロパティを参照します。

アクセスするプロパティのインターフェイスを事前に知っている場合に、
DISPIDとパラメータの型を指定してプロパティを参照します。

@param dispid...
...プロパティのDISPID(メソッドを一意に特定する数値)を指定
します。

@param args プロパティが引数を取る場合に配列で指定します。引数の順序は
最左端の引数のインデックスを0とします。引数が不要な...
...場合は空
配列を指定します。

@param types プロパティが引数を取る場合に配列で引数の型を指定します。引
数の順序は最左端の引数のインデックスを0とします。型の指定
には、WIN32OLE::VARIANTの定...

絞り込み条件を変える

WIN32OLE#_setproperty(dispid, args, types) -> () (6214.0)

DISPIDとパラメータの型を指定してオブジェクトのプロパティを設定します。

...DISPIDとパラメータの型を指定してオブジェクトのプロパティを設定します。

アクセスするプロパティのインターフェイスを事前に知っている場合に、
DISPIDとパラメータの型を指定してプロパティを設定します。

このメソ...
...め、DLLの形式で型情報(TypeLib)を提供しているサーバに対
してはあまり意味を持ちません。

@param dispid プロパティのDISPID(メソッドを一意に特定する数値)を指定
します。

@param args 引数を配列で指定します。...
...序は最左端の引数のインデッ
クスを0とします。プロパティに対する設定値は最右端の要素です。

@param types プロパティの引数の型を配列で指定します。引数の順序は最左端
の引数のインデックスを0とし...

Object#respond_to_missing?(symbol, include_private) -> bool (6177.0)

自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。

...メソッドに対し
BasicObject#method_missing で反応するつもりならば真を返します。

Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。

BasicObject#method_missing を override した場合...
...

@param symbol メソッド名シンボル
@param include_private private method も含めたい場合に true が渡されます

//emlist[例][ruby]{
class Sample
def method_missing(name, *args)
if name =~ /^to_*/
[name, *args] # => [:to_sample, "sample args1", "sample args2"]...
...super
end
end

def respond_to_missing?(sym, include_private)
(sym =~ /^to_*/) ? true : super
end
end

s = Sample.new
s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}

@see Object#respond_to?, BasicObject#method_m...

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

...e 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 sp...
...f 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.

This should only be used for procs that delegate ke...
...ds compatibility with Ruby versions before
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 r...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (385.0)

Enumerator.new(self, method, *args) を返します。

...erator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出す...
...= str.enum_for(:each_byte)
p
(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from being modified
a = [1, 2, 3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentE...
...# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2)...
<< 1 2 3 > >>