# Reference semantics

Methods that alter Container objects usually come in two versions providing either copy or reference semantics where the latter start with 'ref_' to note the reference semantic, for example, add() and ref_add().

Since reference semantics changes the original object, it can be used to save some typing.

co = container()

co
# [a = 1, b = 2]

Although these days this usually can be achieved equally easy using pipes.

co = container() |>
add(b = 2)

Still there might be use cases, where it makes your life a bit easier. Consider the following silly example.

odds = container()
evens = container()
isOdd = function(x) {x %% 2 == 1}

res = sapply(1:10, function(i)
# [2L, 4L, 6L, 8L, 10L]
To summarize, the container package does provide reference semantics, but it should be used with care.