Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results of as_function() should inherit from "function" #735

richierocks opened this issue Mar 4, 2019 · 1 comment


None yet
2 participants
Copy link

commented Mar 4, 2019

Functions created using as_function() do not have a class that includes "function", which means that inherits(fn, "function") confusingly returns FALSE.

# An example function, created with as_function()
is_positive <- as_function(~ . > 0)
# It is a function, as expected
#> [1] TRUE
# It's also a lambda, as expected 
#> [1] TRUE
# It doesn't inherit from function, which isn't expected
inherits(is_positive, "function")
#> [1] FALSE

A possible fix would be to change this line


structure(fn, class = "rlang_lambda_function")


structure(fn, class = c("rlang_lambda_function", "function"))

This comment has been minimized.

Copy link

commented Mar 4, 2019

Agreed, would you like to send a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.