Skip to contents

Prevents modification of objects labelled with the "immutable" S3-class by intercepting assignment during S3-method dispatch and returning an error.

Usage

\method{subset}{immutable}(object, ...) <- value

# S3 method for immutable
[(object, ...) <- value

# S3 method for immutable
[[(object, ...) <- value

# S3 method for immutable
$(object, ...) <- value

# S3 method for immutable
names(x) <- value

# S3 method for immutable
dimnames(x) <- value

\method{colnames}{immutable}(x) <- value

\method{rownames}{immutable}(x) <- value

Arguments

object, x

An R object inherting from the "immutable" S3-class.

...

Catch subset arguments for various dimensions.

value

Not used.

Value

None, throws an error.

Examples

immutable_df <- immutable(data.frame(a=1:5, b=letters[1:5]))
# return immutable data.frame
immutable_df[1:4, ]
#> immutable data.frame 
#>   a b
#> 1 1 a
#> 2 2 b
#> 3 3 c
#> 4 4 d
# return immutable vector
immutable_df$a
#> immutable integer 
#> [1] 1 2 3 4 5