3528 #(1 one 2 two 3 three 4 four 5 five 6 six) |
3528 #(1 one 2 two 3 three 4 four 5 five 6 six) |
3529 inGroupsOf:2 do:[:num :sym | Transcript show:num; show:' is: '; showCR:sym] |
3529 inGroupsOf:2 do:[:num :sym | Transcript show:num; show:' is: '; showCR:sym] |
3530 |
3530 |
3531 #( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ) |
3531 #( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ) |
3532 inGroupsOf:5 do:[:a :b :c :d :e | Transcript show:a;space;show:b;space;show:c;space;show:d;space;showCR:e] |
3532 inGroupsOf:5 do:[:a :b :c :d :e | Transcript show:a;space;show:b;space;show:c;space;show:d;space;showCR:e] |
|
3533 " |
|
3534 ! |
|
3535 |
|
3536 keysAndValuesCollect:aTwoArgBlock |
|
3537 "evaluate the argument, aBlock for every element in the collection, |
|
3538 passing both index and element as arguments. |
|
3539 Collect the returned values and return them." |
|
3540 |
|
3541 |newCollection| |
|
3542 |
|
3543 newCollection := self copyEmpty. |
|
3544 self keysAndValuesDo:[:k :v | |
|
3545 newCollection add:(aTwoArgBlock value:k value:v). |
|
3546 ]. |
|
3547 ^ newCollection |
|
3548 |
|
3549 " |
|
3550 #(one two three four five six) |
|
3551 keysAndValuesCollect:[:key :element | |
|
3552 key even ifTrue:element ifFalse:[element asUppercase]] |
|
3553 |
|
3554 |
|
3555 |d| |
|
3556 |
|
3557 d := Dictionary new. |
|
3558 d at:'a' put:'A'. |
|
3559 d at:'b' put:'B'. |
|
3560 d at:'c' put:'C'. |
|
3561 d at:'d' put:'D'. |
|
3562 d at:'e' put:'E'. |
|
3563 d keysAndValuesCollect:[:key :element | |
|
3564 key first codePoint even |
|
3565 ifTrue:element |
|
3566 ifFalse:[element asLowercase]] |
3533 " |
3567 " |
3534 ! |
3568 ! |
3535 |
3569 |
3536 keysAndValuesDo:aTwoArgBlock |
3570 keysAndValuesDo:aTwoArgBlock |
3537 "evaluate the argument, aBlock for every element in the collection, |
3571 "evaluate the argument, aBlock for every element in the collection, |