On Thu, Nov 19, 2009 at 7:45 PM, Aldric Giacomoni <aldric / trevoke.net> wrote: > Jesù¸ Gabriel y GaláÏ wrote: > >> irb(main):003:1> class << self >> irb(main):004:2> alias :old_sqrt :sqrt >> irb(main):005:2> end > > Ah-ha! My version is underneath. So, what the bit of code I quoted does > is.. It reopens "the class of the module" to make a change in the alias? Yes, module_function creates a method in the singleton class of the module. So you need to enter that singleton class via class << self to be in a place where self is that singleton class, in order to be able to alias that method correctly. > > module Math > > lass << self > lias :old_sqrt :sqrt > nd > > ef self.sqrt x > esult = old_sqrt(x) > f result.is_a? Float > sqrt(#{x})" > lse > esult > nd > nd > end > > >>> puts Math.sqrt(2) > => sqrt(2) Jesus.