Lets say I have an object generated from an xml document it is very deep, so I can reach a value like:
myobject.really[0].long.chain[43].to.travel.to.get.my[5].desired.$.value
If I want to update this property based on it's previous value then I could do it like this:
myobject.really[0].long.chain[43].to.travel.to.get.my[5].desired.$.value =
updateFn(
myobject.really[0].long.chain[43].to.travel.to.get.my[5].desired.$.value,
otherparam1, otherparam2);
This makes my code very hard to read, is there any nice solution to pass a parameter as a reference not by value?
So then my code could look like this:
updateFn(ref, param1, param2) {
// "ref =" act as a reference, "(ref)" act as a value
ref = someThingToDoWithTheOldValue(ref);
}
Call it like this:
updateFn(
myobject.really[0].long.chain[43].to.travel.to.get.my[5].desired.$.value,
otherparam1, otherparam2);
// So I can omit the myobject.really[0].long.chain[43].to.travel.to.get.my[5].desired.$.value = part