Op 16-12-2018 om 12:34 schreef Ben Coman:


On Sun, 16 Dec 2018 at 02:37, Roelof Wobben <r.wob...@home.nl> wrote:
Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

You seem to already have fixed that problem, so just some general feedback...

Your #isNice is an instance method, so you are already inside a FindNiceStrings object.
So you don't need... 
```niceStringsObject := FindNiceStrings new.```
Just use self.

By convention, all #isXXXXX methods should return a Boolean
Your ```isNice: aCollection``` method returns a collection. That would be better renamed #selectNice:

The two #and: messages inside the #select: makes that a bit verbose.
I'd refactor that condition out to its own method, i.e. ```isNice: aWord``` since that was freed up
So you would have:
```    
FindNiceStrings  selectNice: aCollection
^ aCollection select: [ :word | self isNice: word ]
```


> self assert: (FindNiceStrings new checkForbiddenParts: string) equals: true

The "equals: true" part is redundant.

cheers -ben


Thanks,

So the isNice function has all the code with the 2 times and.

and what must i use when a test is false so instead of equals:  false

Roelof

Reply via email to