Skip to content

Commit

Permalink
Add some notes on Try.@function (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored Mar 21, 2022
1 parent ad39786 commit 631e6a6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/docs/@function.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

Create a function that can be called without causing a `MethodError`.

See also: [`istryable`](@ref).
Note that [`Ok`](@ref) and [`Err`](@ref) values can be used in arbitrary functions.
`Try.@function fn` is simply a shorthand for defining a fallback implementation

fn(args...; kwargs...) = Err(Try.NotImplementedError(fn, args, values(kwargs)))

(and auxiliary methods like [`Try.istryable`](@ref)) to help the ["Easier to ask for
forgiveness than permission" (EAFP)](https://github.com/tkf/Try.jl#eafp) approach.

See also: [`Try.istryable`](@ref).

# Examples

Expand Down

0 comments on commit 631e6a6

Please sign in to comment.