| bind | R Documentation |
If the second object is a function, its return value will be wrapped in a
result object of subclass success or failure depending
on whether the function produces an error or warning. Bind is aliased with
then_try.
If the second object is a function, its return value will be wrapped in a
result object of subclass success or failure depending
on whether the function produces an error or warning. then_try is
aliased with bind.
bind(last_result, next_obj, ...)
then_try(last_result, next_obj, ...)
last_result |
|
next_obj |
|
... |
additional arguments to pass to |
result object of subclass success or failure
result object of subclass success or failure
then_try
bind
times3 <- function(x, succeeds = TRUE) {
if (succeeds) success(x * 3)
else failure("func1 failed")
}
success(5) |> bind(times3) |> value()
success(5) |> bind(times3, succeeds = FALSE) |> is_failure()
failure("failed from the start") |> bind(times3) |> is_failure()
failure("failed from the start") |> bind(times3) |> value()
times3 <- function(x, succeeds = TRUE) {
if (succeeds) success(x * 3)
else failure("func1 failed")
}
success(5) |> then_try(times3) |> value()
success(5) |> then_try(times3, succeeds = FALSE) |> is_failure()
failure("failed from the start") |> then_try(times3) |> is_failure()
failure("failed from the start") |> then_try(times3) |> value()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.