GDI
Hi, I’m learning Elixir by doing Exercism courses. I’m on the LogLevel exercise that has to do with Atoms and Cond, I’ve been pulling my hair out over the failing test for a cond evaluation.
Here’s the issue, in the code snippet below, if the log level is 0 and the legacy? is false, it should return an atom of :trace, otherwise it should return an atom of :unknown. The tests for the two lines that have an and operator in the cond evaluation are failing and i don’t know why. I pasted the code in my local editor and there were no errors, I’m confused. Is there something I’m doing wrong?
defmodule LogLevel do
def to_label(level, legacy?) do
# Please implement the to_label/2 function
cond do
(level === 0 and legacy? == false) -> :trace
level === 1 -> :debug
level === 2 -> :info
level === 3 -> :warning
level === 4 -> :error
(level === 5 and legacy? == false) -> :fatal
true -> :unkown
end
end
def alert_recipient(level, legacy?) do
# Please implement the alert_recipient/2 function
end
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Not sure about the rest because I don’t remember the exercise but you have a typo here.
:unkown→:unknownGDI
Oh my God! I feel so dumb! Thank you so much! That solved it. I’d been going at it all day, who knew all I needed was a second pair of eyes. Thanks!
dimitarvp
The woes of dynamic languages.
Elixir is fantastic but Rust would have yelled at you on the first compilation.
Glad that you are unblocked!
GDI
Now I see why programmers will live and die for statically typed languages
dimitarvp
Yep, that’s the reason. In Rust / OCaml / Haskell you just define one sum type (
enumin Rust) and if you have a typo the program doesn’t compile.Still though, for Elixir you can just start doing Ctrl-F (namely find) occurrences of what you think should be in the code and check for yourself. Or you can use
grepwith counting matches and you can manually verify that. There are many ways to reduce the blind spots of the dynamic languages.al2o3cr
Static typing still gives you error messages you have to correctly understand to find the error; for instance, the failing test for this exercise:
https://github.com/exercism/elixir/blob/3231f6ce81662a3e03e6173195390978c71b417d/exercises/concept/log-level/test/log_level_test.exs#L8
will fail on the
assert LogLevel.to_label(0, true) == :unknownline with a message:dimitarvp
True, but let’s not forget that somebody has to make this proper test. This is a fact in this exercise but it’s not always a fact in the commercial projects.
GDI
I definitely have to get better at reading Elixir error messages, thanks for pointing this out. I honestly don’t know how my brain could not parse the typo for hours!
GDI
Thank you! I’ll take note and add that to my debugging toolkit