View Source Witchcraft.Setoid.Proto protocol (Witchcraft v1.0.6-doma)

Protocol for the Elixir.Witchcraft.Setoid type class

For this type class's API, please refer to Elixir.Witchcraft.Setoid

Link to this section Summary

Functions

Compare two setoids and determine if they are equivalent.

Link to this section Types

Link to this section Functions

@spec equivalent?(Witchcraft.Setoid.t(), Witchcraft.Setoid.t()) :: boolean()

Compare two setoids and determine if they are equivalent.

Aliased as ==.

examples

Examples

iex> equivalent?(1, 2)
false

iex> import Kernel, except: [==: 2, !=: 2]
...> %{a: 1} == %{a: 1, b: 2}
false

equivalent?(%Maybe.Just{just: 42}, %Maybe.Nothing{})
#=> false

equivalence-not-equality

Equivalence not equality

baby_harry = %Wizard{name: "Harry Potter", age: 10}
old_harry  = %Wizard{name: "Harry Potter", age: 17}

def chosen_one?(some_wizard), do: equivalent?(baby_harry, some_wizard)

chosen_one?(old_harry)
#=> true