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


  1. Ali ELBaitam on November 25, 2020 at 6:53 am

    In the Instructions section, it is stated that the award_points/2 should “Reject user’s who’s age is < 16". I thought a validate_at_least_age/1:

    def validate_at_least_age(%User{age: age} = user), when age < 16 do

    should work. But in the test module, validate_at_least_age has arity 2; with a second integer argument. Is it meant to make the function more generic and can validate against any cutoff age? or what is the purpose of the second integer argument?


    • Mark Ericksen on November 25, 2020 at 6:58 am

      If you look at the solution, I hope it helps make it clearer. The idea with the /2 arity is so the age cutoff to compare it to can be specified. So I could use the same function to say validate_at_least_age(user, 16) or validate_at_least_age(user, 21).

      So you were very close! Perhaps I need to review the text/instructions to make it more clear.

      • Ali ELBaitam on November 25, 2020 at 9:25 am

        Thanks for the quick replies Mark. I look at the solutions after I make the tests pass. So, you made the function more generic to apply for any cutoff age.

        • Mark Ericksen on November 25, 2020 at 10:09 am

          Another tip is to look more closely at the code for the failing test. Can you tell how the API is intended to be used from it? If so, that helps determine what it wants and how to write it. I often use this outside-in approach to help design code. “This is how the code would work if it existed.” This helps flip the perspective from “how do I make it work?” to focus on designing the API with “how do I want to use this?”

Leave a Comment

You must be logged in to post a comment.