Changes between Version 44 and Version 45 of squeak_faq


Ignore:
Timestamp:
02/24/2015 10:29:55 AM (9 years ago)
Author:
fabio.niephaus
Comment:

Fix code samples for collection protocol

Legend:

Unmodified
Added
Removed
Modified
  • squeak_faq

    v44 v45  
    716716{{{
    717717x := #(1 2 3 4 5).
    718 b := x conform: [:a | (a >= 1) & (a <= 4)].                 "test if all elements meet condition"
     718b := x allSatisfy: [:a | (a >= 1) & (a <= 4)].              "test if all elements meet condition"
     719b := x anySatisfy: [:a | a > 42].                           "test if any element meets condition"
    719720y := x select: [:a | a > 2].                                "return collection of elements that pass test"
    720721y := x reject: [:a | a < 2].                                "return collection of elements that fail test"
     
    722723y := x detect: [:a | a > 3] ifNone: [].                     "find position of first element that passes test"
    723724sum := x inject: 10 into: [:a :c | a + c].                  "sum of elements + 10"
    724 sum :=  fold: [:x :y | x + y ]                              "sum elements"
     725sum := x fold: [:a :b | a + b ]                             "sum elements"
    725726}}}
    726727Beispiele mehrheitlich aus [http://wiki.squeak.org/squeak/5699 Terse Guide to Squeak].