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.

NathanSmutz (5) [Avatar] Offline
#1
In the example:
user> (add-new-user "amit" 1000000)
{"amit" {:id 2, :login "amit", :monthly-budget 1000000, :total-expenses 0}}

:id should be 1. Since this is the first entry added to the map (count @all-users) would have returned 0 so setting :id to (inc current-number) should set it to 1.

So the correction would be:
user> (add-new-user "amit" 1000000)
{"amit" {:id 1, :login "amit", :monthly-budget 1000000, :total-expenses 0}}

This error persists in the example for adding a second user; so, it'll need to be fixed there too.

Message was edited by:
NathanSmutz

Message was edited by:
NathanSmutz