Airline Model - DAML

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.airline

Thank you
Erum

1 Like

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 the flightNumber and airline data 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.

3 Likes

Here’s another take:

  • == is an operator that returns a boolean value, where True means 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 the DA.Assert package and thus needs to be explicitly imported.

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 of assertEq.” assertEq is 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.