mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Update structuralComparison.ts
This commit is contained in:
@@ -2,15 +2,19 @@
|
||||
// identity.
|
||||
|
||||
export default function () {
|
||||
return vec3(-5, 7, 12) === vec3(-5, 7, 12);
|
||||
return new Vec3(-5, 7, 12) === new Vec3(-5, 7, 12);
|
||||
// JavaScript: false
|
||||
// ValueScript: true
|
||||
}
|
||||
|
||||
function vec3(x: number, y: number, z: number) {
|
||||
return { x, y, z };
|
||||
class Vec3 {
|
||||
constructor(public x: number, public y: number, public z: number) {}
|
||||
}
|
||||
|
||||
// There's a lot going on to make this work for the underlying functions being compared, especially
|
||||
// since functions can reference each other recursively. The underlying mechanism is content
|
||||
// hashing. Check the source or open an issue if you'd like to know more.
|
||||
|
||||
// Caveat:
|
||||
// - TypeScript will emit an error for expressions like `[a, b] === [c, d]`.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user