The R Project SVN R

Rev

Rev 53641 | Rev 56184 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 53641 Rev 55047
Line 94... Line 94...
94
  your method definition, in addition to \code{.Object} (always) and
94
  your method definition, in addition to \code{.Object} (always) and
95
  \dots (optionally).  For example, the method for class
95
  \dots (optionally).  For example, the method for class
96
  \code{"traceable"} documented above would be created by a call to
96
  \code{"traceable"} documented above would be created by a call to
97
  \code{\link{setMethod}} of the form:
97
  \code{\link{setMethod}} of the form:
98
 
98
 
99
  \preformatted{
-
 
100
    setMethod("initialize", "traceable",
99
\preformatted{    setMethod("initialize", "traceable",
101
      function(.Object, def, tracer, exit, at, print) \dots
100
      function(.Object, def, tracer, exit, at, print) \dots
102
    )
101
    )
103
  }
102
}
104
 
103
 
105
  In this example, no other arguments are meaningful, and the resulting
104
  In this example, no other arguments are meaningful, and the resulting
106
  method will throw an error if other names are supplied.
105
  method will throw an error if other names are supplied.
107
 
106
 
108
  When your new class extends another class, you may want to call the
107
  When your new class extends another class, you may want to call the
Line 111... Line 110...
111
  class, with special argument \code{x}, but you also want users to be
110
  class, with special argument \code{x}, but you also want users to be
112
  able to set slots specifically.  If you want \code{x} to override the
111
  able to set slots specifically.  If you want \code{x} to override the
113
  slot information, the beginning of your method definition might look
112
  slot information, the beginning of your method definition might look
114
  something like this:
113
  something like this:
115
 
114
 
116
  \preformatted{
-
 
117
    function(.Object, x, ...) \{
115
\preformatted{    function(.Object, x, ...) \{
118
      Object <- callNextMethod(.Object, ...)
116
      Object <- callNextMethod(.Object, ...)
119
      if(!missing(x)) \{ # do something with x
117
      if(!missing(x)) \{ # do something with x
120
  }
118
}
121
 
119
 
122
  You could also choose to have the inherited method override, by first
120
  You could also choose to have the inherited method override, by first
123
  interpreting \code{x}, and then calling the next method.
121
  interpreting \code{x}, and then calling the next method.
124
 
122
 
125
}
123
}