Collection.st
changeset 6052 a7c0dda5e0bc
parent 6042 04414166010e
child 6068 1d5ca1175f3f
equal deleted inserted replaced
6051:e86757447e81 6052:a7c0dda5e0bc
  1356      Between elements (i.e. after each except for the last),
  1356      Between elements (i.e. after each except for the last),
  1357      evaluate betweenBlock.
  1357      evaluate betweenBlock.
  1358      This is a utility helper for collection printers
  1358      This is a utility helper for collection printers
  1359      (for example, to print a space between elements)."
  1359      (for example, to print a space between elements)."
  1360 
  1360 
       
  1361     self obsoleteMethodWarning:'use #do:separatedBy:'.
       
  1362     ^ self do:aBlock separatedBy:betweenBlock
       
  1363 
       
  1364     "
       
  1365      #(1 2 3 4) do:[:el | Transcript show:el]
       
  1366                 inBetweenDo:[ Transcript show:'-']
       
  1367 
       
  1368      (Dictionary with:(1->'one') with:(2->'two'))
       
  1369          do:[:el | Transcript showCR:el printString]
       
  1370          inBetweenDo:[ Transcript showCR:'----']
       
  1371 
       
  1372      (Dictionary with:(1->'one') with:(2->'two'))
       
  1373         associations
       
  1374          do:[:el | Transcript showCR:el printString]
       
  1375          inBetweenDo:[ Transcript showCR:'----']
       
  1376 
       
  1377     "
       
  1378 
       
  1379     "Modified: / 11.2.2000 / 11:23:15 / cg"
       
  1380 !
       
  1381 
       
  1382 do:aBlock separatedBy:betweenBlock
       
  1383     "evaluate the argument, aBlock for each element.
       
  1384      Between elements (i.e. after each except for the last),
       
  1385      evaluate betweenBlock.
       
  1386      This is a utility helper for collection printers
       
  1387      (for example, to print a space between elements)."
       
  1388 
  1361     |first|
  1389     |first|
  1362 
  1390 
  1363     first := true.
  1391     first := true.
  1364     self do:[:element |
  1392     self do:[:element |
  1365         first ifTrue:[
  1393         first ifTrue:[
  1370         aBlock value:element
  1398         aBlock value:element
  1371     ].
  1399     ].
  1372 
  1400 
  1373     "
  1401     "
  1374      #(1 2 3 4) do:[:el | Transcript show:el]
  1402      #(1 2 3 4) do:[:el | Transcript show:el]
  1375                 inBetweenDo:[ Transcript show:'-']
  1403                 separatedBy:[ Transcript show:'-']
  1376 
  1404 
  1377      (Dictionary with:(1->'one') with:(2->'two'))
  1405      (Dictionary with:(1->'one') with:(2->'two'))
  1378          do:[:el | Transcript showCR:el printString]
  1406          do:[:el | Transcript showCR:el printString]
  1379          inBetweenDo:[ Transcript showCR:'----']
  1407          separatedBy:[ Transcript showCR:'----']
  1380 
  1408 
  1381      (Dictionary with:(1->'one') with:(2->'two'))
  1409      (Dictionary with:(1->'one') with:(2->'two'))
  1382         associations
  1410         associations
  1383          do:[:el | Transcript showCR:el printString]
  1411          do:[:el | Transcript showCR:el printString]
  1384          inBetweenDo:[ Transcript showCR:'----']
  1412          separatedBy:[ Transcript showCR:'----']
  1385 
  1413 
  1386     "
  1414     "
  1387 
  1415 
  1388     "Modified: / 11.2.2000 / 11:23:15 / cg"
  1416     "Modified: / 11.2.2000 / 11:23:15 / cg"
  1389 !
  1417 !
  2245 ! !
  2273 ! !
  2246 
  2274 
  2247 !Collection class methodsFor:'documentation'!
  2275 !Collection class methodsFor:'documentation'!
  2248 
  2276 
  2249 version
  2277 version
  2250     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.112 2001-09-24 17:54:02 cg Exp $'
  2278     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.113 2001-09-26 16:14:50 cg Exp $'
  2251 ! !
  2279 ! !
  2252 Collection initialize!
  2280 Collection initialize!