Re: where are the nills come from and how do I get rid of them
Posted by
jtuchel on
Sep 21, 2020; 6:24am
URL: https://forum.world.st/where-are-the-nills-come-from-and-how-do-I-get-rid-of-them-tp5122291p5122292.html
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:
[hidden email]
Fliederweg 1
http://www.objektfabrik.deD-71640 Ludwigsburg
http://joachimtuchel.wordpress.comTelefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1