Morton Goldberg
11/1/2007 8:53:00 PM
On Nov 1, 2007, at 12:24 PM, Mario Ruiz wrote:
> I have this code:
>
> ----------------------
> require 'appliances'
> class Toast<Appliances
> def toast(hole,size,seconds,quantity)
> self.turn_on(seconds,quantity)
> self.chooser(hole,size)
> end
> end
> ----------------------
>
> And from another file:
>
> ---------------------
> require 'toast'
> tuest1=::toast.new('white','big') # from Appliances
> tuest1.buy('Bread','10') # from Appliances
> tuest1.toast('1','200','120','2')
> -----------------
>
> Now I want to create a new variable that automatically has the same
> values ('1','200','120','2' in this case) than the variable tuest1 in
> tostar:
>
> tuest2.toast=tuest1.toast
You don't show enough code for me to do more than make a guess, but
providing
tuest1=::toast.new('white','big')
is really a typo for
tuest1=Toast.new('white','big')
and providing Toast#initialize along with Appliance#buy and
Toast#toast have set up all the instance variables properly, then
tuest2 = tuest1.dup
should do it.
Regards, Morton