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

match.enum.arg: Add support for defining another default value than only the first one #1

Open
aryoda opened this issue Jul 21, 2017 · 1 comment

Comments

@aryoda
Copy link
Owner

aryoda commented Jul 21, 2017

e. g. add a new parameter...

DISADVANTAGE: The default value cannot be recognized in the function signature but only in the documentation!

Is there any chance for a solution that also makes the default value visible in the function signature?

@aryoda
Copy link
Owner Author

aryoda commented Nov 2, 2017

Implementation idea:

Specify default value via an expression in the function declaration:

f <- function(x = EnumWithDefault(color.enum, color.enum$BLUE) {
  x.value <- match.enum.arg(x, color.enum, color.enum$BLUE)
...
 return(x.value)
}

match.enum.arg must always be called with both arguments then to still support all enum values as allowed values. A 3rd argument is required then to pass in the default value.

Any idea to simplify this even more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant