Home Segments Index Top Previous Next

388: Mainline

The following illustrates how you can use inject:into: to add the values in an array:

Workspace
Transcript show: ((Array with: 570 with: 720 with: 640 with: 720) 
                  inject: 0  
                  into: [:sum :element| sum + element]) 
                 printString; cr. 
Transcript 
2650