view · edit · sidebar · attach · print · history

Ruby (Method) Aliasing

<< 32bitVs64bit | Index | AliasMethodAlternative >>

 http://ruby.about.com/od/rubyfeatures/a/aliasing.htm

Code

 #!/usr/bin/env ruby

 class Microwave
   def on
     puts "The microwave is on"
   end

   alias :start :on
 end

 m = Microwave.new
 m.start # same as m.on
view · edit · sidebar · attach · print · history
Page last modified on April 07, 2011, at 02:25 PM