Alternative to enum.each to process a list

If you would like to return the transformed list, you can use Enum.map/2.

Enum.map([1, 2, 3], fn num ->
  num * 2
end)

# [2, 4, 6]