where are the nills come from and how do I get rid of them

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

where are the nills come from and how do I get rid of them

Pharo Smalltalk Users mailing list
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
Reply | Threaded
Open this post in threaded view
|

Re: where are the nills come from and how do I get rid of them

jtuchel
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.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

Reply | Threaded
Open this post in threaded view
|

Re: where are the nills come from and how do I get rid of them

Pharo Smalltalk Users mailing list
Thanks,

I will look further then how to make the tests green

Roelof



Op 21-9-2020 om 08:24 schreef [hidden email]:

> 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
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: where are the nills come from and how do I get rid of them

jtuchel
Hi Roelof,

one thing I sometimes dislike about the way you try to find your way is
that you almost never answer to anything people ask or tell you. This is
not only not helpful, but also off-putting.

I was asking you a simple question: did you get any errors due to nils
or are you just wondering why nils show up in an Inspector?
And I wrote that if this is only about what you see in an inspector, you
shouldn't worry.

Your answer: "I will try to make the tests green".

Red/Green/Yellow tests have never been a topic in this thread. You had
just written "I see nils". Where? When? What did you expect?

Sorry, but that kind of answer just gives me the feeling you are either
not listening or not giving sh*t abot my time. If you aren't listening,
please tell me and if possible give me a reason for it. I will stop
answering your questions and not bother you any more. If you find my
answer isn't helpful, please ask back or tell me what I am
misunderstanding. Maybe we just need to talk about a tiny detail that
hasn't been mentioned before. Or tell me what else is wrong with my
advice in your opinion.

Don't get me wrong: I also tend to ask way too unspecific questions. And
I often really feel bad about it. Most of the time it is just my
helplessness that keeps me from mentioning all the details that are
required to give a decent answer. Asking intelligent questions is hard,
at least in my opinion. It is especially hard if the room around you is
filled with way more question marks than orientation points. But that
shouldn't keep you from helping people who try to help you and ask back
for more details. Sometimes people ask in order to get info on what you
really are asking about. It may or may not help in finding out if I (or
anybody else) can help. And it may help the right answer to your question.


Joachim



Am 22.09.20 um 07:53 schrieb Roelof Wobben via Pharo-users:

> Thanks,
>
> I will look further then how to make the tests green
>
> Roelof
>
>
>
> Op 21-9-2020 om 08:24 schreef [hidden email]:
>> 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.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1