fallthrough | R Documentation |
Permit a pattern matching to continue even if its argument is executed.
fallthrough(fun)
fun |
A result function used in |
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),
...
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.