From 4ce51f79595da9653e36fb356033aef3ca649133 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Tue, 9 Jul 2019 18:18:59 -0700 Subject: [PATCH] Add map assignment to cheat sheet --- gitlab-pages/docs/language-basics/cheat-sheet.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitlab-pages/docs/language-basics/cheat-sheet.md b/gitlab-pages/docs/language-basics/cheat-sheet.md index 58e214dc2..801dce954 100644 --- a/gitlab-pages/docs/language-basics/cheat-sheet.md +++ b/gitlab-pages/docs/language-basics/cheat-sheet.md @@ -35,7 +35,8 @@ title: Cheat Sheet |Variants|
type action is
| Increment of int
| Decrement of int
| |Variant *(pattern)* matching|
const a: action = Increment(5);
case a of
| Increment(n) -> n + 1
| Decrement(n) -> n - 1
end
| |Records|
type person is record
  age: int ;
  name: string ;
end

const john : person = record
  age = 18;
  name = "John Doe";
end

const name: string = john.name;
| -|Maps|
type prices is map(nat, tez);

const prices : prices = map
  10n -> 60mtz;
  50n -> 30mtz;
  100n -> 10mtz;
end

const price: option(tez) = prices[50n];
| +<<<<<<< HEAD +|Maps|
type prices is map(nat, tez);

const prices : prices = map
  10n -> 60mtz;
  50n -> 30mtz;
  100n -> 10mtz;
end

const price: option(tez) = prices[50n];

prices[200n] := 5mtz;
| |Contracts & Accounts|
const destinationAddress : address = "tz1...";
const contract : contract(unit) = get_contract(destinationAddress);
| |Transactions|
const payment : operation = transaction(unit, amount, receiver);
| |Exception/Failure|`fail("Your descriptive error message for the user goes here.")`|