Hello,
I have to make a word count from a sentence so I did this :
countWordsSentence: aString
| splitted result |
splitted := aString splitOn: [ :each | ', ' includes: each ].
result := splitted
inject: Bag new
into: [ :wordBag :word |
wordBag
add: word;
yourself ].
^ result valuesAndCounts
but now I see that the Bag is containing nills.
I tried to delete them by doing this : cleaned := result reject:
[:each | each isNil]
but to my surprise the nills are still there,
Why is that happening and what is the best way to delete them ?
Roelof