Kembali ke Perpustakaan
Region:
Switch to EN
Menengah Exercism • elixir
Try/Rescue/Else/After
Ringkasan Pelajaran
# Introduction
About
The basic try .. rescue concept can be extended to support else and after clauses:
- The
elseblock:- Where a pattern match on the successful result from the try-block occurs.
- The
afterblock:- Where functions are invoked whether the try-block succeeds or is rescued as long as the program is running.
- The result of the
afterblock is not returned to the calling scope.
try do
:a
rescue
_ -> :error
else
:a -> :success
after
:some_action
end
# => :success
Originally from Exercism elixir concepts