Re: [Newbies] Object clone
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 .. but if i change a i dont change b. regards 2008/1/15, Mathieu Suen [EMAIL PROTECTED]: 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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners Mth ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners -- Jakub. ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] Object clone
Jakub == Jakub [EMAIL PROTECTED] writes: Jakub yeah a, b instance of same class and i want copy all instance variables Jakub values to a i want do a := b but i dont want to a is same object as b. In Jakub memory will be two objects a, b with same values .. but if i change a i dont Jakub change b. b := a copy. but you might also want to look at #deepCopy. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] Object clone
Marcin == Marcin Tustin [EMAIL PROTECTED] writes: Marcin So, I take it that clone is a stupider (no postCopy polymorphism) version Marcin of copy (or shallowCopy). Is that right, or does it do something odd? Object#clone looks like an optional-implemented primitive that does a #shallowCopy, but without the fallback-to-smalltalk that #shallowCopy performs. Not sure why those are both in the image. I'd stick with #copy unless I was the implementor of the class being copied, and even then, I'd make copy do the right thing. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] 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 [EMAIL PROTECTED]: 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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners Mth ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners