From a3e5bee1a7bc0004737baf6837b6246479acb2ed Mon Sep 17 00:00:00 2001 From: Peter Ohler Date: Tue, 28 May 2024 17:10:55 -0400 Subject: [PATCH] Update jp.Modify docs --- jp/modify.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jp/modify.go b/jp/modify.go index 30839b3..9e9f96b 100644 --- a/jp/modify.go +++ b/jp/modify.go @@ -12,7 +12,15 @@ import ( "github.com/ohler55/ojg/gen" ) -// MustModify modifies matching nodes and panics on an expression error. +// MustModify modifies matching nodes and panics on an expression error. In +// go, maps can be modified in place as the map itself is modified. Slice +// elements can be replaced in place but elements can not be added or removed +// without potentially needing to replace the original slice with a new +// one. This function and the other jp.Modify functions allow a slice to be +// replaced by stopping at the parent of the target slice and applying a +// modifier function to the target which is then replaced in the +// parent. Without that functionality slice element can only be replaced. +// // Modified elements replace the original element in the data. The modified // data is returned. Unless the data is a slice and modified the returned data // will be the same object as the original. The modifier function will be