The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

epishkin (3) [Avatar] Offline
#1
The countFor(String email) returns 0 for an unknown email in EmailCounter.java
sean.allen (19) [Avatar] Offline
#2
Re: Typo/bug in the count function
If you check the source, you can see its an intentional choice to return 0 for an email that is unknown as said email has no commits.

return count == null ? 0 : ++count;

if we were to use nil rather than 0 to represent no commits then we'd have to deal with handling nil later on.

Given that any unknown email will always have 0 commits and 0 isn't possible for a 'known' email, the use of 0 for unknown emails makes sense to me.
epishkin (3) [Avatar] Offline
#3
Re: Typo/bug in the count function
why do you need ++count ?

I think you need to return 1 or remove ++ and do +1 in the execute
sean.allen (19) [Avatar] Offline
#4
Re: Typo/bug in the count function
Actually you are correct based on its usage.

It should return 1, not 0.

This what I get for reviewing the code when I'm ill.
matthew.jankowski (17) [Avatar] Offline
#5
Re: Typo/bug in the count function
Thanks for pointing this out. A fix has been made and will hopefully be distributed shortly.