Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handle_open = fn
- {:ok, file} -> "First line: #{IO.read(file, :line)}"
- {_, error} -> "Error: #{:file.format_error(error)}"
- end
- IO.puts handle_open.(File.open("existent")) # call with a file that exists
- IO.puts handle_open.(File.open("nonexistent")) # and then with one that doesn't
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement