24件ヒット
[1-24件を表示]
(0.022秒)
別のキーワード
ライブラリ
- ビルトイン (24)
キーワード
-
public
_ method (12) -
singleton
_ method (12)
検索結果
-
Object
# public _ method(name) -> Method (13.0) -
オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。
...vate メソッド名を引数として与えると発生します。
//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}
@see Object#method,Object#public_send,Module#public_instance_method... -
Object
# singleton _ method(name) -> Method (13.0) -
オブジェクトの特異メソッド name をオブジェクト化した Method オブ ジェクトを返します。
...ngで指定します。
@raise NameError 定義されていないメソッド名を引数として与えると発生します。
//emlist[][ruby]{
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m......= k.singleton_method(:hi) # => #<Method: #<Demo:0xf8b0c3c4 @iv=99>.hi>
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) # => NameError
//}
@see Module#instance_method, Method, BasicObject#__send__, Object#send, Kernel.#eval, Object#method...