Learn R Programming

functools (version 0.2.0)

Always: Create a function that that always returns a specific object.

Description

Always(.x) is a closure function that takes any object .x, and returns a function that always returns object .x.

Usage

Always(.x)

Arguments

.x
An object.

Value

A function that itself returns .x.

Examples

Run this code
# comment here
always_0 <- Always(0)
always_0() # 0
always_true <- Always(TRUE)
always_true() # TRUE

Run the code above in your browser using DataLab