# Quick check if Elixir uses structural equivalence when comparing structs # Created: Oct 2022 gtowell defmodule Aaa do @moduledoc """ Just define a minimal struct within the module """ defstruct qq: 0 end defmodule Bbb do @moduledoc """ Just define a struct within this module such that the struct in Bbb is exactly identical to the one in Aaa """ defstruct qq: 0 end defmodule Test do def main do aa=%Aaa{qq: 1} bb=%Bbb{qq: 1} IO.puts("Structural equivalence between Aaa and Bbb #{aa==bb}") aaSame=%Aaa{qq: 1} IO.puts("Two things of same type and contents #{aa==aaSame}") aaCopy=aa IO.puts("Two things where one is copy of other #{aa==aaCopy}") aaDiff = %Aaa{qq: 2} IO.puts("Two things same type, different content #{aa==aaDiff}") end end Test.main