The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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 (109) [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,