1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/fn.R 3\name{fn_body} 4\alias{fn_body} 5\alias{fn_body<-} 6\title{Get or set function body} 7\usage{ 8fn_body(fn = caller_fn()) 9 10fn_body(fn) <- value 11} 12\arguments{ 13\item{fn}{A function. It is lookep up in the calling frame if not 14supplied.} 15 16\item{value}{New formals or formals names for \code{fn}.} 17} 18\description{ 19\code{fn_body()} is a simple wrapper around \code{\link[base:body]{base::body()}}. It always 20returns a \verb{\\\{} expression and throws an error when the input is a 21primitive function (whereas \code{body()} returns \code{NULL}). The setter 22version preserves attributes, unlike \verb{body<-}. 23} 24\examples{ 25# fn_body() is like body() but always returns a block: 26fn <- function() do() 27body(fn) 28fn_body(fn) 29 30# It also throws an error when used on a primitive function: 31try(fn_body(base::list)) 32} 33