Open harell opened 3 years ago
dataclasses
Car <- function(model = NA_character_, hp = NA_real_) return( data.frame(modek = model, hp = hp) ) Car <- make_immutability(Car, freez = True) car <- Car(model = "Mercedes-Benz S-Class", hp = 180) car$hp <- 200 # fails because object is immutable
Why use make_immutability()?
make_immutability()
Use cases:
dataclasses
module ] (https://docs.python.org/3/library/dataclasses.html#frozen-instances)