Equals

EqualsFn(value_1, value_2, ...)
Equals(value_1, value_2,...)
Equals(value_1, value_2, ...)
Equals(value_1, value_2, ...)
equals(value_1, value_2, ...)
Equals(value_1, value_2, ...)

Description

The Equals function tests equivalence between a list of values.

Two functions are considered equal if their syntax is identical. For example:

Equals(Query(Lambda('a', 5)), Query(Lambda('a', 5)))
true

Parameters

Argument Type Definition and Requirements

value_1

Any

A single value.

value_2

Any

A single value.

…​

Any

Optional - Any number of additional values to compare for equality.

Returns

true when all provided parameters are equal, false otherwise.

Examples

The following query returns true because fire is equivalent to fire.

try
{
    Value result = await client.Query(
        EqualsFn("fire", "fire")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
BooleanV(True)
result, err := client.Query(
	f.Equals("fire", "fire"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
true
System.out.println(
    client.query(
        Equals(Value("fire"), Value("fire"))
    ).get());
true
client.query(
  q.Equals('fire', 'fire')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
true
result = client.query(
  q.equals("fire", "fire")
)
print(result)
True
try {
  println(Await.result(
    client.query(Equals("fire", "fire")),
    5.seconds
  ))
} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
true

The following query returns true because null values (and their equivalents) are equal to themselves:

try
{
    Value result = await client.Query(
        EqualsFn(Null(), Null())
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
BooleanV(True)
result, err := client.Query(
	f.Equals(nil, f.Null()))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
true
System.out.println(
    client.query(
        Equals(Null(), Null())
    ).get());
true
client.query(
  q.Equals(null, null)
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
true
result = client.query(
  q.equals(None, None)
)
print(result)
True
try {
  println(Await.result(
    client.query(Equals(Null(), Null())),
    5.seconds
  ))
} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
true

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!