hash-accessors: Accessor methods for the hash class.

Description Details Value Author(s) See Also Examples

Description

R style accesors for the hash-class.

Details

These are the hash accessor methods. They closely follow an R style.

$ is a look-up operator for a single key. The native $ method is used. The key is taken as a string literal and is not interpreted.

[[ is the look-up, extraction operator. It returns the values of a single key.

[ is a subseting operator. It returns a (sub) hash with the specified keys. All other keys are removed.

Value

\$ and [[ return the value for the supplied argument. If a key does not match an existing key, then NULL is returned with a warning.

[ returns a hash slice, a sub hash with only the defined keys.

Author(s)

Christopher Brown

See Also

hash, values, .set, as.list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  h <- hash()
  h <- hash( letters, 1:26 )

  h$a 			
  h$a <- "2"   
  h$z <- NULL          # Removes 'z' from 

  h[['a']] 
  h[['a']] <- 23

  h[ letters[1:4] ]    # hash with a,b,c,d
  h[ letters[1:4] ] <- 4:1

hash documentation built on May 1, 2019, 7:28 p.m.