# NOT RUN {
#simple object
object <- 0
#set attributes
object %$% A <- 1
object %$% B <- 2
object %$% A %$% I <- 10
object %$% A %$% J <- 20
#get attributes
object %$% A
object %$% B
object %$% A %$% I
object %$% A %$% J
#quoted version
#(for R packages)
object %$% "A"
object %$% "B"
#this doesn't work
#object %$% A [1]
#however, this does work
(object %$% A) [1]
#function object
#(using lexical scope)
g <- function ()
{ A <- 2
B <- 2
function (x)
A * B + x
}
f <- g ()
#get environment members
f %@% A
f %@% B
# }
Run the code above in your browser using DataLab