在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
class A def self.ask1 puts "the method of class" end def ask2 puts "the method of instance" end end #类的实例对象的方法,方法属于类所生成New出来的实例对象。 def a.tell end p a.methods.length p a.class.instance_methods.length p A.instance_methods.length p a.public_methods.length p a.class.public_instance_methods.length 输出:51 50 51 50 class A def self.ask1(n1,n2) puts "the method of class" end def ask2(n1) puts "the method of instance" end end a=A.new p a.method(:ask2).arity p A.method(:ask1).arity 输出:1 2 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论