method
Value.SameBacking
Recognize retained immutable sources before repeating derived work.
Example
original := store.Object(store.Values{
"title": store.String("Home"),
})
snapshot := original
rebuilt := store.Object(store.Values{
"title": store.String("Home"),
})
fmt.Println(original.SameBacking(snapshot)) // true
fmt.Println(original.SameBacking(rebuilt)) // falseArguments
| Argument | Type | Description |
|---|---|---|
other | Value | Another retained immutable value to compare with the receiver. |
Returns
True for shared container backing or exactly matching scalar values; false for different kinds or backing.
boolHow it works
This checks source identity without traversing container contents. Separately constructed containers can return false even when their serialized contents match.
Scalar numbers compare their bits, so positive and negative zero differ. Empty lists share their empty backing.
Keep caches bounded and retain their source Values. Retaining a source also retains the immutable data reachable from it.
Full signature
func (value Value) SameBacking(other Value) boolRelated types
ValueAn immutable scalar, object, list, or populated document value.