new_power_of_two <- function() {
structure(list(), class = "PowerOfTwo")
}
# power2[i] calls this method
`[.PowerOfTwo` <- function(x, i) 2^i
power2 <- new_power_of_two()
p2 <- power2[2]
# p2 = 4
p8 <- power2[8]
# p8 = 256
p16 <- power2[16]
# p16 = 65536
cat("p2 =", p2, "\n")
cat("p8 =", p8, "\n")
cat("p16 =", p16, "\n")