Hyperlinkv0.8.0-beta.28

Equal

Equal.symbolconsteffect/Equal.ts:52
"~effect/interfaces/Equal"

Defines the unique string identifier for the Equal interface.

When to use

Use when you implement custom equality and need the computed property key for the equality method.

Details

This is a pure constant with no allocation or side effects.

Example (Implementing Equal on a class)

import { Equal, Hash } from "effect"

class UserId implements Equal.Equal {
  constructor(readonly id: string) {}

  [Equal.symbol](that: Equal.Equal): boolean {
    return that instanceof UserId && this.id === that.id
  }

  [Hash.symbol](): number {
    return Hash.string(this.id)
  }
}
Source effect/Equal.ts:521 lines
export const symbol = "~effect/interfaces/Equal"
Referenced by 4 symbols