You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Object by value help

2 replies [Last post]
Guest's picture
Guest

Hello i have a custom object I created and it i am trying to clone it with an identical object but it seems the object is by reference.

Here is just a sample of what I am doing to give you an idea possibly what I am looking for.

My object has one property that I can read and write to. (get set) named ID. It also has a constructor.

local myobject:myobject &oID = create myobject:myobject();
&oID.ID="cool1";

local myobject:myobject &oID2 = create myobject:myobject();
&oID2=&oID;

&oID2.ID="NOTCool";

If i now check &oID.ID and &oID2.ID they are both set to "NOTCool". I assumed create would have created a new instance of my object but it is looking as though that is incorrect.

Any suggestions on how i might be able to make this work?

Thanks.

Guest's picture
Guest (not verified)
Re: Object by value help

May I know why you assigned:

&oID2=&oID;

I think the above statement causing both the objects point to same memory location.
correct me if i am wrong.

vivek6686's picture
User offline. Last seen 1 year 27 weeks ago. Offline
Joined: 09/27/2010
Posts: 8
Re: Object by value help

&oID2=&oID.ID;
may be this could work

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
The question below is to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.