怎么绕过private方法的限制,直接调用private方法。
class AAA private def private_method puts 'this is private method' end endend
?两种方式
1.用send
a = AAA.newa.send(:private_method)
?2.用重写方式
class XXX 《 AAA def private_method super endendx = XXX.newx.private_method
怎么绕过private方法的限制,直接调用private方法。
class AAA private def private_method puts 'this is private method' end endend
?两种方式
1.用send
a = AAA.newa.send(:private_method)
?2.用重写方式
class XXX 《 AAA def private_method super endendx = XXX.newx.private_method