Code check request
Hey alchemists,
I'm getting started with Elixir and as an exercise I am reimplementing a small utility I wrote in Python in Elixir. I've gotten most of the core functionality in place but I have no way to tell if what I'm writing is bad / idiomatic Elixir code I was wondering if you could take a quick look and give me your thoughts. I care mostly about code correctness instead of efficiency though I'll take any feedback.
https://github.com/ChasingLogic/pub_ip_monitor
Specifically lib/comparator.ex is where most of the business happens.
Thanks in advanced and if this isn't the place to post things like this let me know.
5 comments · 67% upvoted · other discussions
Sure I got a couple tips :)
It is common to use atoms as keys in keyword lists and maps instead of strings. Some syntax is only available if you do, and it will have a side benefit of making you programs slightly smaller / faster ;)
in
compare_ipsthecondwould look better as anifso like this:
My preference would be to reduce one more step and do the matching in the function head, like so: