Ben, Ron, I made a small example, and it works as you said it would:
<br/><br/>a := #( #(1 2) #(3 4)).
<br/>b := a asOrderedCollection.
<br/>b => an OrderedCollection(#(1 2) #(3 4))
<br/>c := b select: [ :i | (i first) = 3 ].
<br/>c => an OrderedCollection(#(3 4))
<br/>d := c first
<br/>d => #(3 4)
<br/>d at: 2 put: 5
<br/>d => #(3 5)
<br/>b => an OrderedCollection(#(1 2) #(3 5))
<br/><br/>Okay, I will check my other code.
<br/><br/>Sincerely,
<br/><br/>Joe.
<br/><br/><br/><br/><div class='shrinkable-quote'><br/>> On Jul 26, 2016, at 6:25 PM, Ben Coman [via Smalltalk] <<a href="/user/SendEmail.jtp?type=node&node=4908114&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> wrote:
<br/>>
<br/>> Hi Joe,
<br/>>
<br/>> As Ron said, you should not be getting a copy. If you still have a
<br/>> problem, perhaps best if you post code for a complete example:
<br/>> * class definition (with just two instance variables)
<br/>> * instance variable accessor methods
<br/>> * instance creation & adding to collection
<br/>> * select statement
<br/>> * updating object
<br/>>
<br/>> cheers -ben
<br/>>
<br/>> On Wed, Jul 27, 2016 at 5:53 AM, Ron Teitelbaum <[hidden email]> wrote:
<br/>>
<br/>> > Hi Joe,
<br/>> >
<br/>> > If the orderedCollection contains your object DrivingDays then select should give you the object and not a copy.
<br/>> >
<br/>> > You don't need to add it back to the collection just update the object.
<br/>> >
<br/>> > Check your code for anything that might be making a copy.
<br/>> >
<br/>> > All the best,
<br/>> >
<br/>> > Ron Teitelbaum
<br/>> >
<br/>> >
<br/>> > -----Original Message-----
<br/>> > From: [hidden email] [mailto:[hidden email]] On Behalf Of Joseph Alotta
<br/>> > Sent: Tuesday, July 26, 2016 3:04 PM
<br/>> > To: [hidden email]
<br/>> > Subject: [Newbies] indexing into a collection
<br/>> >
<br/>> > Greetings,
<br/>> >
<br/>> > I have a OrderedCollection of DrivingDays.
<br/>> >
<br/>> >
<br/>> > an OrderedCollection(2016-01-02| quigley s| nil|18§
<br/>> > 2016-01-03| marianos fresh| nil|5§
<br/>> > 2016-01-04| fresh thyme| nil|5§
<br/>> > 2016-01-05| panda express| nil|3§
<br/>> > 2016-01-06| peets| nil|7§
<br/>> > 2016-01-07| starbucks| nil|3§)
<br/>> >
<br/>> > I want to select aDrivingDay object from the list by date, update it by adding mileage and places visited and put it back into the list.
<br/>> >
<br/>> > If I #select the OrderedCollection, I get a copy of the item, not the same one in the OrderedCollection.
<br/>> >
<br/>> > How do I select an item in the list for update?
<br/>> >
<br/>> > Sincerely,
<br/>> >
<br/>> > Joe.
<br/>> _______________________________________________
<br/>> Beginners mailing list
<br/>> [hidden email]
<br/>> <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_top" rel="nofollow" link="external">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br/>>
<br/>>
<br/>> If you reply to this email, your message will be added to the discussion below:
<br/>> <a href="http://forum.world.st/indexing-into-a-collection-tp4908090p4908113.html" target="_top" rel="nofollow" link="external">http://forum.world.st/indexing-into-a-collection-tp4908090p4908113.html</a><br/>> To start a new topic under Squeak - Beginners, email <a href="/user/SendEmail.jtp?type=node&node=4908114&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br/>> To unsubscribe from Squeak - Beginners, click here.
<br/>> NAML
</div><br/>
        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://forum.world.st/indexing-into-a-collection-tp4908090p4908114.html">Re: indexing into a collection</a><br/>
Sent from the <a href="http://forum.world.st/Squeak-Beginners-f107673.html">Squeak - Beginners mailing list archive</a> at Nabble.com.<br/>