diff --git a/website/src/playground/files/root/tutorial/structuralComparison.ts b/website/src/playground/files/root/tutorial/structuralComparison.ts index 241d821..0e1b9aa 100644 --- a/website/src/playground/files/root/tutorial/structuralComparison.ts +++ b/website/src/playground/files/root/tutorial/structuralComparison.ts @@ -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]`. //