-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Description
Hey there!
I'm trying to set up a "two-step" method dispatch in S7, I'd like my generic function to automatically pick different versions depending on the classes of the arguments, and each version should accept slightly different parameter names.
For example:
method(fun, list(class_character, class_integer, class_numeric)) <- function(x, int_1, num_1) { ... }
method(fun, list(class_numeric, class_integer, class_character)) <- function(x, int_2, chr_1) { ... }Then, when I call it, the right version kicks in based on the order of classes—and I'd use the matching parameter names:
fun(x, int_1 = xxx, num_1 = xxx) # x is character, and uses the first version
fun(x, int_2 = xxx, chr_1 = xxx) # x is numeric, and uses the second versionAny idea if this is possible? And if so, what's the cleanest way to pull it off?
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels