Slot "salary":
[1] 55000
Slot "union":
[1] TRUE
Note that the member variables are calledslots, referenced via the@sym-
bol. Here’s an example:
> joe@salary
[1] 55000
We can also use theslot()function, say, as another way to query Joe’s
salary:
> slot(joe,"salary")
[1] 55000
We can assign components similarly. Let’s give Joe a raise:
> joe@salary <- 65000
> joe
An object of class "employee"
Slot "name":
[1] "Joe"
Slot "salary":
[1] 65000
Slot "union":
[1] TRUE
Nah, he deserves a bigger raise that that:
> slot(joe,"salary") <- 88000
> joe
An object of class "employee"
Slot "name":
[1] "Joe"
Slot "salary":
[1] 88000
Slot "union":
[1] TRUE
224 Chapter 9