jstraitiff (2) [Avatar] Offline
Just a quick suggestion. You mention at the bottom of page 118 (in v05) "a more practical example" with the following code:

defmodule NumberHelper do
def odd?(num) do
if rem(num, 2) == 1, do: true, else: false

This isn't really a practical example. Because you can just return an expression, you'll never want to use the construct of if's returning just true/false. So, you can more simply write:

defmodule NumberHelper do
def odd?(num), do: rem(num, 2) == 1

I get that you were trying to go for simplicity in the example, but you should be pushing readers to learn that everything is an expression and can be returned easily. Therefore, maybe a slightly more complex example would be more practical smilie

sjuric (108) [Avatar] Offline
Re: Note about section 3.3.2 the "IF" section
Hi Joe,

Thank you for this sensible comment!

After reading your post, I agree that this example is not very practical and I'll try to make it more illustrative.

Thanks again!

Best regards,