quii / learn-go-with-tests

Learn Go with test-driven development
MIT License
22.21k stars 2.81k forks source link

Expanding on maps delete to make it more consistent with add and update #787

Open reyncode opened 4 months ago

reyncode commented 4 months ago

In this PR I expanded on the Delete method in the maps chapter to be consistent with other CRUD operations in the case that the word being deleted does not exist. The same Update switch structure is used to capture errors with a minor change ErrWordDoesNotExist to make it applicable to both update and delete operations.

nivethan-me commented 4 months ago

it seems like the current version is more consistent with the language. since delete(map, key) doesn’t return anything, and will do nothing if the specified key doesn’t exist in Go.