nope, it takes also the last one and that schould not be used.


Op 16-5-2019 om 21:51 schreef Roelof Wobben:
I think this is better

 ^  String streamContents: [:stream |
 gifts 
    do: [:each | stream nextPutAll: each ]
    separatedBy: [ stream nextPut: $,; space ]
  stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last] 


Op 16-5-2019 om 21:47 schreef Roelof Wobben:
oke, and then do something like :

stream :=
String streamContents: [:stream |
  gifts 
    do: [:each | stream nextPutAll: each ]
    separatedBy: [ stream nextPut: $,; space ]
     
stream nextputAll: 'all'; nextPut: ','; nextPut: gifts last
]

stream nextputAll: 'all' 
stream nextPut: ','
stream nextPut: gifts last


Roelof


Op 16-5-2019 om 21:30 schreef Esteban Maringolo:
Maybe this is a better way to build what you want.
String streamContents: [:stream |
  gifts 
    do: [:each | stream nextPutAll: each ]
    separatedBy: [ stream nextPut: $,; space ]
]

Esteban A. Maringolo


On Thu, May 16, 2019 at 4:21 PM Roelof Wobben <r.wob...@home.nl> wrote:
Hello,

Im testing all my solutions with critiz and can solve almost all problems,

Only this one I cannot figure out.

I have this code
(gifts allButLast
                inject: ''
                into: [ :str :each | str , each , ', ' ]) , 'and ' , gifts last ]

and critiz says I should use a stream .

How can I make this work ? 

Roelof




Reply via email to