Learn R Programming

mlr3misc (version 0.15.0)

get_private<-: Assign Value to Private Field

Description

Convenience function to assign a value to a private field of an R6 instance.

Usage

get_private(x, which) <- value

Value

The R6 instance x, modified in-place. If it is not an R6 instance, NULL is returned.

Arguments

x

(any)
Object whose private field should be modified.

which

(character(1))
Private field that is being modified.

value

(any)
Value to assign to the private field.

Examples

Run this code
library(R6)
item = R6Class("Item", private = list(x = 1))$new()
get_private(item)$x
get_private(item, "x") = 2L
get_private(item)$x

Run the code above in your browser using DataLab