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

Explore method dispatch to avoid if(class(thing)) do (function) else do (other_function) #705

Open
njtierney opened this issue Aug 16, 2024 · 1 comment

Comments

@njtierney
Copy link
Collaborator

njtierney commented Aug 16, 2024

e.g., Use method dispatch inside of calculate to avoid


    if (is.greta_mcmc_list(values)) {
      result <- calculate_greta_mcmc_list(
        target = target,
        values = values,
        nsim = nsim,
        tf_float = tf_float,
        trace_batch_size = trace_batch_size
      )
    } else {
      result <- calculate_list(
        target = target,
        values = values,
        nsim = nsim,
        tf_float = tf_float,
        env = parent.frame()
      )
    }

Thanks @maelle for the suggestion

@maelle
Copy link
Contributor

maelle commented Aug 16, 2024

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

No branches or pull requests

2 participants