Sorry, I misses the "all" part at the end (I don't see how that could add something, but if it's in the requirements...) Then it should be like this: String streamContents: [:stream | gifts allButLast do: [:each | stream nextPutAll: each ] separatedBy: [ stream nextPut: $,; space ]. stream nextPutAll: ' all, '; nextPutAll: gifts last]. Esteban A. Maringolo On Thu, May 16, 2019 at 4:52 PM Roelof Wobben <r.wobben@home.nl> wrote:
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.wobben@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