From 03089d7e42bdb2d0066b1c6bd0818bcce1b1d044 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Mon, 19 Oct 2020 08:44:10 +0200 Subject: [PATCH] Added basic nargin function --- R/nargin.R | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 R/nargin.R diff --git a/R/nargin.R b/R/nargin.R new file mode 100644 index 0000000..e843e87 --- /dev/null +++ b/R/nargin.R @@ -0,0 +1,11 @@ +#' @title Number of function input arguments +#' @description Returns the number of arguments passed to the parent function +#' @return An integer +#' @author Waldir Leoncio +#' @note This function only makes sense inside another function +nargin <- function() { + # FIXME: returning 0 because it is using its own envir instead of parent's + print(parent.env(environment())) + length(as.list(match.call(envir = parent.env(environment())))) - 1 + # length(ls(envir=parent.env(environment()))) - 1 +} \ No newline at end of file