You cannot view this unit as you're not logged in yet. Go to Account to login.
5 Comments
Francisco Quinteroon November 24, 2020 at 7:02 pm
Awesome and thank you!
These pattern matching exercises have clear my mind and now I feel more confident. In the beginning I thought I wouldn’t complete the exercises without looking at the solution but gave them a try, read my notes, and tests passed!
The second one was a tricky one, though, but was a nice thing to learn.
It’s a good question and this may sound like I’m dodging the question, but I’d say it really depends. 🙂
I prefer a case statement when the code is pretty simple. Like just a simple transformation. When the body of code in a case clause starts to get more involved or complex, I think about doing it differently. Separate function clauses can be easier to test as well.
Sometimes reading some code I notice I needed to practice and put in my mind exactly these things.
And here was a good sample to blow my mind.
I like the exercise with tests, It was very helpful.
In some books you don’t see this important things you need to understand and it’s very simple now for me.
Thank’s!
Awesome and thank you!
These pattern matching exercises have clear my mind and now I feel more confident. In the beginning I thought I wouldn’t complete the exercises without looking at the solution but gave them a try, read my notes, and tests passed!
The second one was a tricky one, though, but was a nice thing to learn.
Is it a better practice to create multiple function clauses or to create one clause with a case statement?
It’s a good question and this may sound like I’m dodging the question, but I’d say it really depends. 🙂
I prefer a
case
statement when the code is pretty simple. Like just a simple transformation. When the body of code in a case clause starts to get more involved or complex, I think about doing it differently. Separate function clauses can be easier to test as well.Sometimes reading some code I notice I needed to practice and put in my mind exactly these things.
And here was a good sample to blow my mind.
I like the exercise with tests, It was very helpful.
In some books you don’t see this important things you need to understand and it’s very simple now for me.
Thank’s!
Awesome! I’m so glad you’re enjoying it!