/ message / src / main.adl
main.adl
 1  // This example demonstrates the definition and initialization of a "struct" in Leo.
 2  program message.alpha {
 3      // The "Message" struct.
 4      struct Message {
 5          // A struct member named "first" with type "field".
 6          first: field,
 7          // A struct member named "second" with type "field".
 8          second: field,
 9      }
10  
11      // The "main" function of this Leo program takes a "Message" struct type as input.
12      // To see how to input variable "m" is passed in open up `inputs/message.in`.
13      transition main(m: Message) -> field {
14  
15          // 1. Define the "Message" type.
16          // 2. Use brackets `{ }` to enclose the struct members.
17          // 3. Define each struct member `name : value`.
18          let m1: Message = Message {
19              first: m.first,
20              second: m.second,
21          };
22  
23          // Access the members of a struct with dot syntax.
24          // `struct_name.member`
25          return m1.first + m1.second;
26      }
27  
28      // The constructor is configured to prevent upgrades.
29      @noupgrade
30      async constructor() {}
31  }