Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,是否可以覆盖“puts”方法并将其替换为调用两次“puts”的函数?
例如:
class IO def puts str puts str puts str end end
我知道这个例子很愚蠢,但我需要它来做其他事情。基本上,我想覆盖一个函数,但我希望覆盖函数包括对原始覆盖函数的调用。
class IO alias puts_orig puts def puts str puts_orig str puts_orig str end end