co = container("x", 9)
replace(co, 9, 0)
replace(co, "x", 0)
try({
replace(co, "z", 0) # old element ("z") is not in Container
})
replace(co, "z", 0, add = TRUE) # just add the zero without replacement
d = dict(a = 1, b = "z")
replace(d, 1, 1:5)
replace(d, "z", "a")
try({
replace(d, "a", 2) # old element ("a") is not in Dict
})
Run the code above in your browser using DataLab