目次
1、arityメソッド
2、dupメソッド
3、instance_of?メソッド
arityメソッド
メソッドが受け付ける引数の数を返します
class Sumple
def num(a,b,c)
puts "#{a}#{b}#{c}"
end
end
s = Sumple.new
p s.method(:num).arity
=>3
dupメソッド
オブジェクトのコピーを作成するメソッド
a = [1,2,3]
b = a.dup
p b
=>[1, 2, 3]
instance_of?メソッド
オブジェクトが直接のインスタンスである時真(true)を返す
class Sumple
end
class C < Sumple
end
s = C.new
p s.instance_of?(C)
=>true