# Container
co = container(a = 1, 2, b = 3, 4)
at2(co, 1)
at2(co, "a")
at2(co, 2)
try(at2(co, "x")) # index 'x' not found
try(at2(co, 5)) # index 5 exceeds length of Container
# Dict
d = dict(a = 1, b = 3)
at2(d, 1)
at2(d, "a")
at2(d, 2)
try(at2(d, "x")) # index 'x' not found
try(at2(d, 5)) # index 5 exceeds length of Dict
# dict.table
dit = dict.table(a = 1:3, b = 4:6)
at2(dit, 1)
at2(dit, "a")
at2(dit, 2)
try(at2(dit, "x")) # index 'x' not found
try(at2(dit, 5)) # index 5 exceeds length of dict.table
Run the code above in your browser using DataLab