init: Initialize Class Instance

View source: R/init.R

initR Documentation

Initialize Class Instance

Description

Function called on oClass instance when it is created. Users create init methods to customize creation behavior for their Classes. All init methods should return the Instance. init_next calls the objects next init methods. init_next should only be used inside if init.

Usage

init(x, ...)

init_next(x, ...)

Arguments

x

environment of class "Instance"

...

named fields inherited by the class instance or passed to methods

Value

environment of class "Instance"

Functions

  • init_next: Initialize the inherited Class.

Examples


Animal <- oClass("Animal")

init.Animal <- function(self, x, y){
  self$x <- x
  self$y <- y
  self
}

turtle <- Animal(5, 10)
turtle$x == 5    # TRUE
turtle$y == 10   # TRUE



oops documentation built on March 18, 2022, 5:16 p.m.