From Ruby to Elixir:

@sb8244

From Ruby to Elixir -
iex(1)> Enum.reduce([1, 2, 3], 0, fn num, ac → if num > max, do: num, else: ac end)
error: undefined variable “max”
└─ iex:6
** (CompileError) cannot compile code (errors have been logged)
command not working (page 42)

1 Like

Oof, thanks for this! I will make sure it’s fixed (and have an action item to go through every code entry in book to make sure it works properly.)

If it’s not clear, the ac variable should be called max here. I originally called it accumulator, but I find max easier to understand as that represents the purpose of the accumulation.