What should I be doing with my Dictionary.erase() method?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dumuz

I have a lot of moments in my script where I erase variables from dictionaries and I have a lot of warnings of their return. Do people really just use the # warning-ignore:unused_variable throughout their a lot of their script, or is there a common practice using these return values?

:bust_in_silhouette: Reply From: skysphr

If attempting to delete a key that does not exist would cause no harm or unexpected behaviour in your code’s architecture, then yeah, you can simply ignore the warnings. But if you feel that it may be useful down the road in catching some random programming error, you should probably error check for it and emit a warning when the returned value is false. I usually mute the warnings for ignoring returns of connect() calls for example and so far I haven’t run into any trouble for it xD