elixir-koans
elixir-koans copied to clipboard
04_atoms.ex has unclear expectations
I'm new to Elixir and using these koans. First of all: thanks! I really appreciate them.
For the 04_atoms koans, I wasn't clear what was expected. For example, assert true == ___
and assert false == ___
can be most easily completed by simply repeating true
and false
.
I was guessing that perhaps it should be completed with assert true == :true
.
Another thought is that these could be triple-equal, such as assert :true === ___
?
Bottom line: while this definitely succeeding in driving me to think more about atoms, I would have appreciated more of a nudge.
If someone more experienced with Elixir can explain the intent, I would be happy to submit a PR to improve this koan.
@DaneWeber thank you for the feedback! Sorry it has taken so long to get a response. Sometimes it's really hard to build an example that provides enough hint to keep folks on the straight and narrow w/o giving everything away. If you have any ideas for how to help these examples explain themselves better, we'd love to see them! Maybe even as easy as a little more in the description? Or a comment?
Thanks for the response! 😄 I'm on a pretty slow cycle too.
So, I'm an elixir newbie, but my suggestion was the following:
assert :true === ___
I would think that would point to a solution of assert :true === true
. I'm assuming that is the intent of this exercise, but I wanted to make sure I'm not missing a deeper solution.
Ah, I think I missed the subtlety of your suggestion. I like it! I agree that it would seem a bit easier to intuit what the lesson is trying to show you by going from atom to boolean rather than the opposite. Fwiw, I don't think the threequals is really necessary. I believe the only difference is numeric equality.
The only difference between == and === is that === is stricter when it comes to comparing integers and floats
What do you think @felipesere @ukutaht ?
Thank you for the suggestions @DaneWeber!
I agree with @iamvery here. Showing the atom is a good improvement to the exercise but I would keep the double-equals. In my experience the convention is to always use double-equals as the default and frankly seeing a triple-equals in an elixir codebase would be pretty confusing to me.
Interesting! I came directly from 03_numbers.ex
which uses ===
several times, and I clearly missed that it's only stricter when it comes to integers & floats. I was carrying baggage from other languages.
I wonder if we could do more to emphasize "looky ===
matters for numbers"
Found this issue because I also had no idea what assert true == ___
and assert false == ___
were expecting.
My suggestion would be to follow the same pattern from the first two koans in Numbers:
assert true == :true == ___ // expects `true`
assert false == :false == ___ // expects `true`