calledBy: Check if a Function Was Called by Another Function

View source: R/calledBy.R

calledByR Documentation

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")

Arguments

fun

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

Value

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

Examples

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

exams.forge documentation built on Aug. 21, 2025, 5:41 p.m.