fallthrough {optional} | R Documentation |
Fallthrough function
Description
Permit a pattern matching to continue even if its argument is executed.
Usage
fallthrough(fun)
Arguments
fun |
A result function used in |
Details
fallthrough(fun)
can be applied to a result function fun
inside a
match_with()
pattern.
If there is a match, this will make the pattern matching
continue through the other conditions at the end of the result function fun
.
match_with(variable,
pattern, fallthrough(result-function),
...
Examples
library(magrittr)
a <- 4
match_with(a,
. %>% if (. %% 2 == 0).,
fallthrough( function() "This number is even" ),
. %>% if ( sqrt(.) == round(sqrt(.)) ).,
function() "This number is a perfect square"
)
## [1] "This number is even" "This number is a perfect square"
[Package optional version 2.0.1 Index]