Airline Model - DAML
- ZerumOP 1
Hi Team,
I am new to DAML and I am learning by using Airline Model. I have question from Airline DAML model about t
he === used and if you can please explain the following code.ticket.flightNumber === flight.flightNumber
ticket.airline === flight.airlineThank you
Erum - Mate_Varga 3
Hi Erum
As @a_putkov replied to you here,
===is the infix version of the assertEq function. Which means, these two lines are checking and making sure that the CheckIn exercise is performed with a flight that matches theflightNumberandairlinedata stored on the ticket. If the values are not equal the rest of the exercise - checking for the seat’s Class, creating a BoardingPass and exercising AssingSeat on it - won’t be performed. - Gary_Verhaegen
Here’s another take:
-
==is an operator that returns a boolean value, whereTruemeans the two values are equal. It is part of the “base language” (Prelude) so it is always available. -
===is an operator that throws an exception if the two values are not equal. It’s mostly useful in tests. It is part of theDA.Assertpackage and thus needs to be explicitly imported.
-
- Stephen
Daml’s documentation search works well with symbolically-named functions. Head over there and type in
===, and the only result that comes up is “Infix version ofassertEq.”assertEqis documented nearby, if you’re getting acquainted with that function.General-purpose search engines are not so great with searching for symbols; I strongly recommend trying the Daml Docs search first.