h <- hash( c('a','b','c'), 1:3 )
# NAMED ACCESS
h$a # 1
h$c # 3
# class of values change automatically
class(h$a) # integer
h$a <- 1.1
class(h$a) # numeric
# values can contain more complex objects
h$a <- 1:6
h
h$a <- NULL # DELETE key 'a', will return null
# INTERPRETED ACCESS
h[[ "a" ]] <-"foo" # Assigns letters, a vector to "foo"
nm = "a"
# SLICE ACCESS
h[ nm ] <- "bar" # h$a == bar
h[ nm ] <- NULL
# Slice
h[ keys(h) ]
h[ keys(h) ] <- list( 1:2, 1:3 )
h
Run the code above in your browser using DataLab