Roelof, I guess your are taking about what you see in the inspector... There is nothing to worry about. Try inspecting wordBag asOrderedCollection and see if there are still nils. Or ask the Bad for occurencesOf: nil. It is completely normal to see nils in an Inspector on a Set or Bag. Has to do with internals of Set's and Bag's. These nils are there, but not for you ;-) Joachim Am 21.09.20 um 08:16 schrieb Roelof Wobben via Pharo-users:
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
-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:jtuchel@objektfabrik.de Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1