[Newbies] Re: Help! can't see inside a Bag

Joseph Alotta joseph.alotta at gmail.com
Wed Apr 20 21:25:04 UTC 2016


There is a possibility of duplicates.  For example, if I go to Starbucks buy a coffee, then buy a second cup.  There would be two transactions same amount, same day.

What about OrderedCollection?

How do I send #asSet to the bag, give that the bag is an instance variable in my larger object?





> On Apr 20, 2016, at 2:43 PM, cbc [via Smalltalk] <ml-node+s1294792n4891054h23 at n4.nabble.com> wrote:
> 
> HI Joe,
> A Bag is a structure to hold multiple, possibly repeating, objects in it.  One of the benefits is to know how many times an object is inside of the bag - how many times it repeats.
> 
> Bag is implemented with a Dictionary it in - the key is the objects that you put into the bag, and the value is the count of how many times it was put into the bag (hence all of the 1's that you see - they were probably just added once to the bag).
> 
> The explorer is optimized to make Dictionary navigation fast and convenient for normal Dictionaries - you can see and select the key, and get to see the details of the values in the dictionary.
> It is not optimized for looking at the dictionary in the Bag, where you care about the key (and mostly not about the value - at least for your use case).
> 
> To explore the values in the Bag, I would suggest one of two ways of getting at the data:
> 1> send #asSet to the bag, and explore that
> 2> send #keys to the dictionary, and explore that
> Either should work.
> 
> One more thing to think about - if you aren't going to have multiples of your Transaction objects (or don't care to know that you have multiple of them) in your Bag, you might want to consider using a Set instead.
> 
> Thanks,
> cbc
> 
> On Wed, Apr 20, 2016 at 12:31 PM, Joseph Alotta <[hidden email]> wrote:
> Help!
> 
> 
> I have a data structure as the screenshot below shows.
> 
> There is a Bag with Transaction objects.
> 
> I can’t see inside the Transaction objects?
> 
> Why is there a Dictionary?
> 
> I can see the beginning of the transaction data, but I can’t the the whole line?
> 
> When I explore, it opens a window on Integer 1.  Where are all the 1s coming from?
> 
> 
> Sincerely,
> 
> Joe.
> 
> 
> here is the link: https://www.flickr.com/photos/jalotta/26480315621/
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 
> _______________________________________________ 
> Beginners mailing list 
> [hidden email] 
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://forum.world.st/Help-can-t-see-inside-a-Bag-tp4891049p4891054.html
> To start a new topic under Squeak - Beginners, email ml-node+s1294792n107673h12 at n4.nabble.com 
> To unsubscribe from Squeak - Beginners, click here.
> NAML





--
View this message in context: http://forum.world.st/Help-can-t-see-inside-a-Bag-tp4891049p4891076.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20160420/1f73ab08/attachment.htm


More information about the Beginners mailing list