From: Derek Cannon on 19 Apr 2010 04:39 > maybe you could show us a sample use case of method overloading since > i cannot think of one right now ;-) Sure. A simple example of what I wanted to do (using method overloading in this example for lack of better know-how): Class XYZ def initialize(title, days, time, professor) @title = title @days = days @time = time @professor = professor end def initialize(title, days, time, professor, lab_time, lab_days) @title = title @days = days @time = time @professor = professor @lab_time = lab_time @lab_days = lab_days end end -- Posted via http://www.ruby-forum.com/.
From: Jesús Gabriel y Galán on 19 Apr 2010 04:47 On Mon, Apr 19, 2010 at 10:39 AM, Derek Cannon <novellterminator(a)gmail.com> wrote: >> maybe you could show us a sample use case of method overloading since >> i cannot think of one right now ;-) > > Sure. A simple example of what I wanted to do (using method overloading > in this example for lack of better know-how): > This one is easy: Class XYZ def initialize(title, days, time, professor, lab_time=nil, lab_days=nil) @title = title @days = days @time = time @professor = professor @lab_time = lab_time @lab_days = lab_days end end Jesus.
First
|
Prev
|
Pages: 1 2 Prev: [ANN] McBean 0.3.0 released Next: how to scrap data with Nokogiri from this page? |