Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. handle_open = fn
  2. {:ok, file} -> "First line: #{IO.read(file, :line)}"
  3. {_, error} -> "Error: #{:file.format_error(error)}"
  4. end
  5. IO.puts handle_open.(File.open("existent")) # call with a file that exists
  6. IO.puts handle_open.(File.open("nonexistent")) # and then with one that doesn't
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement