Iterator.st
changeset 294 859e8e4e8c4a
parent 290 f4fbe0881e1b
child 355 6d4757eab329
equal deleted inserted replaced
293:2086fa8d3ef3 294:859e8e4e8c4a
   115      i := Iterator on:b.
   115      i := Iterator on:b.
   116      i do:[:j |
   116      i do:[:j |
   117         j printNL
   117         j printNL
   118      ].
   118      ].
   119                                                                         [exEnd]
   119                                                                         [exEnd]
   120 "
   120  an iterator, simulating a collection of the lines
   121 
   121  in a file:
       
   122                                                                         [exBegin]
       
   123      |i b|
       
   124 
       
   125      b := [:whatToDo |
       
   126                |s line|
       
   127 
       
   128                s := 'smalltalk.rc' asFilename readStream.
       
   129                [s atEnd] whileFalse:[
       
   130                   line := s nextLine.
       
   131                   whatToDo value:line.
       
   132                ].
       
   133                s close
       
   134           ].
       
   135 
       
   136      i := Iterator on:b.
       
   137      i do:[:j |
       
   138         j printNL
       
   139      ].
       
   140                                                                         [exEnd]
       
   141 "
   122 ! !
   142 ! !
   123 
   143 
   124 !Iterator class methodsFor:'instance creation'!
   144 !Iterator class methodsFor:'instance creation'!
   125 
   145 
   126 on: aBlock
   146 on: aBlock
   293 ! !
   313 ! !
   294 
   314 
   295 !Iterator class methodsFor:'documentation'!
   315 !Iterator class methodsFor:'documentation'!
   296 
   316 
   297 version
   317 version
   298     ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.2 1996-05-09 12:28:31 cg Exp $'
   318     ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.3 1996-05-10 07:59:39 cg Exp $'
   299 ! !
   319 ! !