ST 4U 286: Interesting Collection Methods
Today's Smalltalk 4 You looks at some of the more interesting methods in the collection hierarchy. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll look at some of the more useful methods in the Collection class hierarchy, and use some examples to illustrate. We're using VA Smalltal, so fire that up and look at class collection:
Select the ANSI-API category, and have a look at the methods - you can count on the ones here being implemented (and implemented this way) across all the major Smalltalks. Some of the methods here are "new" - in the sense that the various vendors have only added them to their distributions in the last few years. Today we'll take a look at some of these methods:
coll1 := #(1 2 3 4 5). coll2 := #(4 5 6 7 8). coll3 := #(1 1 2 3 3 4 4 5). coll1 anySatisfy: [:each | each < 10]. true coll1 allSatisfy: [:each | each < 3]. false coll1 noneSatisfy: [:each | each > 10]. true coll1 intersection: coll2. Set(4 5 ) coll2 occurrencesOf: 2 0 coll3 sorted: [:a : b | b <= a] (5 4 4 3 3 2 1 1)
The results of executing each line of code is after each line (using Display from the workspace menu). If you don't follow why, go ahead and experiment with the examples, and debug through them.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Technorati Tags: smalltalk, collection
Enclosures:
[st4u286-iPhone.m4v ( Size: 5781385 )]