Learn R Programming

exams.forge (version 1.0.11)

calledBy: Check if a Function Was Called by Another Function

Description

Determines whether the current function call was initiated by a specified function. This is useful for conditional behavior depending on the caller.

Usage

calledBy(fun = "exams2pdf")

called_by(fun = "exams2pdf")

Value

A logical value: TRUE if the current call was triggered by fun, otherwise FALSE.

Arguments

fun

Character string specifying the name of the calling function to check for. Defaults to "exams2pdf".

Examples

Run this code
funB <- function() { calledBy("funA") }
funA <- function() { funB() }
funA()  # Returns TRUE because funB was called by funA

Run the code above in your browser using DataLab