We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Avoiding Common Bugs with `Keyword.pop` in Elixir
221
clicks

Source: lakret.net
The author recently encountered a bug in an Elixir project where an option was passed with the wrong name, which passed the tests and went into production unnoticed. Traditionally, `Keyword.get/3` is used to fetch keyword arguments in Elixir functions, which can silently ignore misspelled options leading to bugs. The author suggests using `Keyword.pop/3`, which ensures unexpected options are not passed into a function, as a way to catch such errors quickly during development. A performance benchmark shows that the performance difference between the two approaches is negligible in most real-world scenarios. The article highlights the benefits of using `Keyword.pop/3` to improve reliability and avoid a class of bugs while maintaining code readability.
Related posts
© HashMerge 2025