jstraitiff (2) [Avatar] Offline
#1
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
end
end

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
end

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

-Joe
sjuric (86) [Avatar] Offline
#2
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,
Saša