Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

DOLLAR.Object

Makes the fields and methods of an Object accessible via the \$ and the [[ operator


Description

Makes the fields and methods of an Object accessible via the $ operator. This method is never called explicitly, but through an indirect usage of the $ operator, e.g. obj$name or obj$getValue().

1) This method will first search for a get<Name>() method, e.g. if name has the value "age", a getAge() will be looked for. If such a method exists it will be called with the Object as the first and only argument, e.g. getAge(this).

A get<Name>() is only looked for if <name> is not a private field. A private field is a name beginning with a . (period). The rational for this naming convention is to be consistent with how ls() works, which will not list such members by default.

2) If no such method exists, first then, this method will look a field in the Object can has the name name.

3) If such neither exists, a method with name name will be searched for and returned.

4) Otherwise, a static field will be looked for.

5) If no fields or methods are found at all, NULL is returned.

Usage

## S3 method for class 'Object'
this$name
  ## S3 method for class 'Object'
this[[name, exact=TRUE]]

Arguments

name

The name of the field or method to be accessed.

Value

Returns the value of a field or a method (function). If no such field or method exists, NULL is returned.

Author(s)

Henrik Bengtsson

See Also

For more information see Object.

Examples

## Not run: For a complete example see help(Object).

R.oo

R Object-Oriented Programming with or without References

v1.24.0
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.