This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
elrond_wasm::imports!(); | |
/// One of the simplest smart contracts possible, | |
/// it holds a single variable in storage, which anyone can increment. | |
#[elrond_wasm::derive::contract] | |
pub trait Adder { | |
#[view(getSum)] | |
#[storage_mapper("sum")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Options section | |
setopt correct # Auto correct mistakes | |
setopt extendedglob # Extended globbing. Allows using regular expressions with * | |
setopt nocaseglob # Case insensitive globbing | |
setopt rcexpandparam # Array expension with parameters | |
setopt nocheckjobs # Don't warn about running processes when exiting | |
setopt numericglobsort # Sort filenames numerically when it makes sense | |
setopt nobeep # No beep | |
setopt appendhistory # Immediately append history instead of overwriting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def format_amount(value) | |
result = sprintf("%10.2f", value.abs) | |
if value < 0 | |
result + "-" | |
else | |
result + " " | |
end | |
end | |
def print_line(label, value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_balance(account) | |
printf "Debits: %10.2f\n", account.debits | |
printf "Credits: %10.2f\n", account.credits | |
if account.fees < 0 | |
printf "Fees: %10.2f-\n", -account.fees | |
else | |
printf "Fees: %10.2f\n", account.fees | |
end | |
printf " ———-\n" | |
if account.balance < 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var item; | |
try | |
{ | |
item = previousItem; | |
} | |
catch (ReferenceError) | |
{ | |
item = new Item(); | |
previousItem = item; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleShape = (shape) => { console.log(shape.area()); } | |
class Shape | |
{ | |
constructor(width = 2) | |
{ | |
this.width = width; | |
} | |
area() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stop = () => { console.log("stop called"); } | |
const go = () => { console.log("go called"); } | |
const colour = 'red'; | |
const handleColour = | |
{ | |
'red' : stop, | |
'amber' : stop, | |
'green' : go, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (colour) | |
{ | |
case 'red': | |
case 'amber': | |
stop(); | |
break; | |
case 'green': | |
case 'flashing amber': | |
go(); | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (expression) | |
{ | |
case value1: | |
// code executed if expression matches value1 | |
[break;] | |
case value2: | |
// code executed if expression matches value2 | |
[break;] | |
... | |
case valueN: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Fruit": | |
[ | |
{ | |
"Name": "Banana", | |
"Colour": "Yellow" | |
}, | |
{ | |
"Name": "Apple", | |
"Colour": "Green" |
NewerOlder