method

Value.SameBacking

Recognize retained immutable sources before repeating derived work.

Example

go
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))  // false

Arguments

ArgumentTypeDescription
otherValueAnother 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.

bool

How 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

Related types

  • Value

    An immutable scalar, object, list, or populated document value.

Related guides