logo       

Object copyFrom: [was: Object clone]: msg#00066

lang.smalltalk.squeak.beginners

Subject: Object copyFrom: [was: Object clone]

Hi Jakub,

on Tue, 15 Jan 2008 18:29:53 +0100, you wrote:

yeah a, b instance of same class and i want copy all instance variables
values to a i want do a := b but i dont want to a is same object as b. In
memory will be two objects a, b with same values ..

If you mean to have class Person and (aPerson := Person new), (bPerson := Person new) and later you want that aPerson has exactly the same instance variables as bPerson, then you might want

aPerson copyFrom: bPerson

This is not often used (it's rather at the system level), because most Smalltalk developers set instance variables by mutators, like

aPerson name: bPerson name.
aPerson address: bPerson address.
...

See also the comment in #copyFrom: on the instance side of Object.

Enjoy Smalltalk :)

/Klaus

but if i change a i dont
change b.

regards

2008/1/15, Mathieu Suen <mathk.sue@xxxxxxxxx>:

Hi Jakub

I don't really understand your question.
What is a and b? Are they instance of the same class?

On Jan 14, 2008, at 10:42 PM, Jakub wrote:

> hello,
>
> i want do i want set var a as all instance vars of b. Something s
> clone - coppy of one object. I look for clone command in SBE book
> but i found nothing.
>
> Thnx.
>
> --
> Jakub. _______________________________________________
> Beginners mailing list
> Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

Mth



_______________________________________________
Beginners mailing list
Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx
http://lists.squeakfoundation.org/mailman/listinfo/beginners






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise