HI Staffan,

I'm not sure what you were expecting.   But in both m1 and m2 you pass back
the same object you passed in.  So in the main part of the program a and b
both point to the same object.

Since they are the same object any change made to b is a change made to a.

In m3 you create a new object and pass that object back.  Now in the main
program a points to one object and b points to a second object.  A change
made to the second object will not be seen in the first object.

--
Mark Miesfeld

On Wed, Oct 24, 2012 at 5:40 AM, Staffan Tylen <staffan.ty...@gmail.com>wrote:

> Yesterday I posted an error (in this thread) that I had not been able to
> find a solution for, but later on I found out why this was happening and I
> informed you that this was solved. However I feel that the cause to this
> error may be common to many, especially ooRexx newcomers like myself. So I
> just wish to illustrate 3 different coding techniques of which only one
> gives the correct result even if they all look OK for an untrained eye. My
> reported error was caused because I had used the technique shown in method
> m2.
>
> I hope this can be of use to some.
> Staffan
>
> c = .myclass~new
> a = .array~new
>
> a[1] = "a"
> b = c~m1(a)
> say a[1]
> say b[1]
>
> a[1] = "a"
> b = c~m2(a)
> say a[1]
> say b[1]
>
> a[1] = "a"
> b = c~m3(a)
> say a[1]
> say b[1]
>
> ::class myclass
> ::method m1
> use arg arg1
> arg1[1] = "aa"
> return arg1
>
> ::method m2
> use arg arg1
> myarg1 = arg1
> myarg1[1] = "aa"
> return myarg1
>
> ::method m3
> use arg arg1
> myarg1 = arg1~copy
> myarg1[1] = "aa"
> return myarg1
>
>
>
> I have the following strange scenario in a listview dialog, where all
>> items have user data associated with them via setItemData:
>>
>> - select an item (item 5 for example)
>> - create a new item (for example item 9) based on the selected, with a
>> modified version of item 5's item data
>> - delete item 9
>> - select item 5 again
>> - create a new item - this fails because item 5 now seems to contain item
>> 9's item data
>>
>> Having run several variations of this it looks like getItemData retrieves
>> the data from the last setItemData and not the data associated with the
>> item passed to getItemData (based on listview~selected).
>>
>> Could this be a possibility or do I have a bug in my code that I haven't
>> been able to locate?
>>
>>
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Oorexx-users mailing list
> Oorexx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to