Description of the class.

Details

Details of the class.

Public fields

  • name: first name.

  • hair: hair color.

Methods

Public methods


Method new()

Usage

Person$new(name = NA, hair = NA)

Arguments

name

First name.

hair

Hair color, if known.

Details

Create a new Person object.

Returns

A person object.

Examples

Person$new("Ann", "black")


Method set_hair()

Usage

Person$set_hair(val)

Arguments

val

The new hair color.

Details

Set new hair color.

Returns

The new color, invisibly.

Examples

ann <- Person$new("Ann", "black")
ann$hair
ann$set_hair("red")
ann$hair


Method greet()

Usage

Person$greet()

Details

Make the person greet.

Examples

ann <- Person$new("Ann", "black")
ann$greet()


Method clone()

The objects of this class are cloneable with this method.

Usage

Person$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

## ------------------------------------------------ ## Method `Person$new` ## ------------------------------------------------ Person$new("Ann", "black")
#> Hello, my name is Ann.
#> <Person> #> Public: #> clone: function (deep = FALSE) #> greet: function () #> hair: black #> initialize: function (name = NA, hair = NA) #> name: Ann #> set_hair: function (val)
## ------------------------------------------------ ## Method `Person$set_hair` ## ------------------------------------------------ ann <- Person$new("Ann", "black")
#> Hello, my name is Ann.
ann$hair
#> [1] "black"
ann$set_hair("red") ann$hair
#> [1] "red"
## ------------------------------------------------ ## Method `Person$greet` ## ------------------------------------------------ ann <- Person$new("Ann", "black")
#> Hello, my name is Ann.
ann$greet()
#> Hello, my name is Ann.