Last active
August 31, 2016 13:24
-
-
Save expede/0ce06c184fc1bf030001f87e88611dc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Exceptional | |
OtherFile.read("./existing_file.txt") ~> String.length | |
# 19 | |
OtherFile.read("./missing.file") ~> String.length | |
# %OtherFile.NotFoundError{ | |
# message: "File not found at ./missing.file", | |
# path: "./missing.file" | |
# } | |
OtherFile.read("./existing_file.txt") | |
|> exception_or_continue(String.length) | |
# 19 | |
OtherFile.read("./existing_file.txt") | |
~> fn file -> | |
file | |
|> String.to_charlist | |
|> Enum.filter&(&1 == 101) | |
|> Enum.count | |
end.() | |
# 2 | |
OtherFile.read("./missing.file") | |
~> fn file -> | |
file | |
|> String.to_charlist | |
|> Enum.filter&(&1 == 101) | |
|> Enum.count | |
end.() | |
# %OtherFile.NotFoundError{ | |
# message: "File not found at ./missing.file", | |
# path: "./missing.file" | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment