where are the nills come from and how do I get rid of them
Posted by Pharo Smalltalk Users mailing list on Sep 21, 2020; 6:16am
URL: https://forum.world.st/where-are-the-nills-come-from-and-how-do-I-get-rid-of-them-tp5122291.html
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