8f60accc24
- Reenable code block tabs - Reeneble code blocks highlighting
8.5 KiB
8.5 KiB
id | title |
---|---|
cheat-sheet | Cheat Sheet |
import Syntax from '@theme/Syntax';
Primitive | Example |
---|---|
Strings | "Tezos" |
Characters | "t" |
Integers | 42 , 7 |
Natural numbers | 42n , 7n |
Unit | unit |
Boolean |
|
Boolean Logic |
|
Mutez (micro tez) | 42mutez , 7mutez |
Address | "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" , "KT1JepfBfMSqkQyf9B1ndvURghGsSB8YCLMD" |
Addition | 3 + 4 , 3n + 4n |
Multiplication & Division | 3 * 4 , 3n * 4n , 10 / 5 , 10n / 5n |
Modulo | 10 mod 3 |
Tuples |
|
Types | type age is int , type name is string |
Includes | #include "library.ligo" |
Functions (short form) |
|
Functions (long form) |
|
If Statement |
|
Options |
|
Assignment | const age: int = 5; |
Assignment on an existing variable ⚠️ This feature is not supported at the top-level scope, you can use it e.g. within functions. Works for Records and Maps as well. |
age := 18; , p.age := 21 |
Type Annotations | ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) |
Variants |
|
Variant (pattern) matching |
|
Records |
|
Maps |
|
Contracts & Accounts |
|
Transactions |
|
Exception/Failure | failwith ("Your descriptive error message for the user goes here.") |
Primitive | Example |
---|---|
Strings | "Tezos" |
Characters | "t" |
Integers | 42 , 7 |
Natural numbers | 42n , 7n |
Unit | unit |
Boolean |
|
Boolean Logic |
|
Mutez (micro tez) | 42mutez , 7mutez |
Address | ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address) , ("KT1JepfBfMSqkQyf9B1ndvURghGsSB8YCLMD": address) |
Addition | 3 + 4 , 3n + 4n |
Multiplication & Division | 3 * 4 , 3n * 4n , 10 / 5 , 10n / 5n |
Modulo | 10 mod 3 |
Tuples |
|
Types | type age = int , type name = string |
Includes | #include "library.mligo" |
Functions |
|
If Statement |
|
Options |
|
Variable Binding | let age: int = 5 |
Type Annotations | ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) |
Variants |
|
Variant (pattern) matching |
|
Records |
|
Maps |
|
Contracts & Accounts |
|
Transactions |
|
Exception/Failure | failwith ("Your descriptive error message for the user goes here.") |
Primitive | Example |
---|---|
Strings | "Tezos" |
Characters | "t" |
Integers | 42 , 7 |
Natural numbers | 42n , 7n |
Unit | unit |
Boolean |
|
Boolean Logic |
|
Mutez (micro tez) | 42mutez , 7mutez |
Address | ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address) , ("KT1JepfBfMSqkQyf9B1ndvURghGsSB8YCLMD": address) |
Addition | 3 + 4 , 3n + 4n |
Multiplication & Division | 3 * 4 , 3n * 4n , 10 / 5 , 10n / 5n |
Modulo | 10 mod 3 |
Tuples |
|
Types | type age = int; , type name = string; |
Includes | #include "library.mligo" |
Functions |
|
If Statement |
|
Options |
|
Variable Binding | let age: int = 5; |
Type Annotations | ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) |
Variants |
|
Variant (pattern) matching |
|
Records |
|
Maps |
|
Contracts & Accounts |
|
Transactions |
|
Exception/Failure | failwith ("Your descriptive error message for the user goes here."); |