[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to get the variables from a class

Mario Ruiz

11/1/2007 4:25:00 PM

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

But it doesn't work.

Anybody knows how can I do it?

Thank you.
--
Posted via http://www.ruby-....

5 Answers

Mario Ruiz

11/1/2007 4:50:00 PM

0

I forgot it, before I did tuest2.toast=tuest1.toast I did:

tuest2=::toast.new('black','biggest') # from Appliances
--
Posted via http://www.ruby-....

Mario Ruiz

11/1/2007 4:52:00 PM

0

The error is:
wrong number of arguments
--
Posted via http://www.ruby-....

Morton Goldberg

11/1/2007 8:53:00 PM

0

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

harry k

2/26/2012 8:55:00 PM

0

On Feb 26, 12:43 am, Warhol <mol...@hotmail.com> wrote:
> Sound Cannot Travel In A Vacuum
>
> http://www.youtube.com/watch?v=q...
>
> Thats why we do not hear the constant Lion roar of the Sun's fusion
> activity.
>
> waves need a medium to propagate... Sound waves work like a truck
> hitting a line of cars. The wave travels through the next line from
> back to front but would not if there were no cars.
>
> How, then, do radio waves travel through interstellar space?
>
> Radio waves are like Sound waves, all waves need a medium... even in
> rocket in vacuum space needs a medium to push against or the object
> will be pushed back into the atmosphere...
>
> And the other misconception is that rays are Waves... Rays are beams
> and do not need any medium... why we have light from the sun but no
> sound.
>
> Its not because you hear nothing that the Lion doesn't Roar...http://www.youtube.com/watch?v=m...
>
> On Feb 24, 11:50 pm, Warhol <mol...@hotmail.com> wrote:
>
>
>
> > Moon Hoax - Rockets CANNOT work in space
>
> > one of the biggest space hoaxes of all time!
>
> > rocket propulsion cannot work in space.
>
> > you get tricked by being told about newtons third law and how the
> > propellant pushes against the body so therefore (equal opposite) has
> > to push the rocket.
>
> > but newtons third law ironically proves this to be false if viewed
> > from the other way round, the propellant cannot push against a vacuum
> > (zero force) so in turn (equal and opposite) applies zero force to the
> > rocket/vehicle itself.
>
> > can anyone find me a video of a rocket, firecracker or something
> > similar creating force in a vacuum?- Hide quoted text -
>
> - Show quoted text -

I see, science per warthog as it was in 1017.

Harry K

David E. Powell

2/26/2012 11:07:00 PM

0

On Feb 26, 3:54 pm, harry k <turnkey4...@hotmail.com> wrote:

snip

> I see, science per warthog as it was in 1017.

Or, to get things back to Naval science, the Empress Dowager of China
throwing a coin in a bowl of water and telling her Admirals that
they'd be foolish to make those Iron ships they wanted to build
because metal obviously could not float in water.

> Harry K