Booleans
Booleans are typed bool in LIGO :
Loading...
Common logical operators on bool :
Loading...
Comparing Values
Only values of the same type can be natively compared, i.e. int, nat, string, tez, timestamp, address, etc… However some values of the same type are not natively comparable, i.e. maps, sets or lists. You will have to write your own comparison functions for those.
Loading...
⚠️ Notice that equality is checked with a single ==.
⚠️ Also notice the use of != for the inequality operator.
Conditionals
Conditional logic enables forking the control flow depending on the state.
Loading...
⚠️ Notice the then clause and else clause are blocks of instructions between { and }.
⚠️ Notice the ; at the end of if instruction.
Your mission
We want to conditionally change the engine attribute (third number) to 1 only if it is equal to 0.
1- Define a condition if the engine attribute equal 0. Don’t forget the attributes are defined as strings.
2- If the condition is met, compute the new shipcode value in a constant *modified\ship and return modified_ship. Otherwise, return the my_ship* constant (given as parameter of the function).
⚠️ If you have installed LIGO then you can test the execution of the modify_ship function by running the following command:
Loading...