Deep operations: getIn and setIn
Last updated
Last updated
Modélico objects support deeply getting values given a path, and deeply setting values given a path and a value.
Using the Animal
and Person
classes used in the and the
getIn
Notice that the path items are strings for regular fields and numbers for M.List
. There is another dedicated way for M.Maybe
for the case where the value is not present, consisting of an array with two items: the default value, and the path item that applies for the inner type.
This is equivalent to the getIn
method above
setIn
To set values deeply, a very similar approach is used: