Part 3: the language


What can it do? - Usefull methods

not part of the language, but I thought they were great when I first saw them:
  • conversion between any two collection classes:
          aCollection as: AnotherCollectionClass

            #(2 4 6 8) as: Interval
             -> (2 to: 8 by: 2)

  • collecting into stream:
              ACollectionClass streamContents: aUnaryBlock

            String streamContents: [:str |
                        str nextPutAll: 'Hello, world'.
                      str nextPut: $!
              ]


    -> 'Hello, world!'
  • progress meters:
              aString displayProgressAt: aPoint from: initialIndex to: finalIndex during: aUnaryBlock

              'hang on a minute....'
                      displayProgressAt: Sensor cursorPoint
                       from: 0 to: 60
                       during: [:bar |
                              1 to: 60 do: [:second |
                                         bar value: second.
                                         (Delay forSeconds: 1) wait]]                

sqk00037.gif (1381 bytes)