You cannot view this unit as you're not logged in yet. Go to Account to login.


  1. Ali ELBaitam on November 23, 2020 at 6:38 am

    I got stumped when I attempted the first exercise comparing against the value of “age”. I thought the case expression should be the “age” value which I get from the function parameter: def classify_user(%User{age: age})… I didn’t know how it will work:

    case age do
    age when age >=18 -> {…}
    age when age {…}
    _ ->

    I found it weird and different from other languages. I looked back at the examples in the lesson and they all looked unusual. The case expression usually is not a constant in other languages but in the lesson examples it is: case nil do, case true do, case 10 do!

    Eventually, I had to look at the solution and realized that the case expression is the entire User structure not the age value only.

    I understand the solution but I just wanted to share what someone new to Elixir struggles with.

    • Mark Ericksen on November 23, 2020 at 10:57 am

      Thanks for sharing your experience. I’ll give it some more thought about how it could be improved. Feel free to email me directly with any suggestions! 🙂

      • Ali ELBaitam on November 24, 2020 at 3:23 am

        I think I was overthinking what the exercises are asking 🙂 I have gone through many and codewars exercises and so far pattern matching using function is what I used and never needed looks like a secondary construct in Elixir (pattern matching on functions which looks similar is used more often). One important thing I learned from this lesson though is the as an expression which will be useful as I am progressing with Elixir.

        • Mark Ericksen on November 24, 2020 at 5:28 am

          Yes, the same pattern matching that applies in a function header applies in a case statement. However a case statement is often needed because you need to call a function to get the data you need to analyze.

Leave a Comment

You must be logged in to post a comment.