Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created August 6, 2016 19:33
Show Gist options
  • Save ivancorrales/bf315fa558b00933aae02110b1fa170b to your computer and use it in GitHub Desktop.
Save ivancorrales/bf315fa558b00933aae02110b1fa170b to your computer and use it in GitHub Desktop.
Reading a file With Elixir
defmodule Mix.Tasks.Elixchool.FileProcessor do
use Mix.Task
def run(filePath) do
case File.read(filePath) do
{:ok, body} -> process(body)
{:error, reason} -> errorHandler(reason)
end
end
defp process(content) do
IO.puts content
end
defp errorHandler (error) do
IO.inspect error
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment