You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
file - main.aq
//look modules in source files (can use external lib)
import math;
//import clr namespace
import clr System;
//import clr class
import clr System.Console;
//you can alias imported static members for more readability
import clr System.Console { method1_name as m1, method2_name as m2 }
fn main ()
{
// static methods import as a [class_name]_[method_name] ex:
console_write("some string");
// just write() on importing System.Console;
m1();
m2();
//call add function form math module
add(10, 1);
}
file - math.aq
//declare new module
module math
//create async method with _async postfix
pub fn add_async(x int, y int) Task<int>
{
// use await for create state machine for waiting result and continue op
// it helps create write async code as sync
return await go {
do_stuff();
return x + y;
};
}
// create private for module function
fn do_stuff()
{
// do some havy work
}
//sample pass lambda delegate
fn lamda_sample(func fn(int) int) int
{
return func(10);
}
// create public for module function
pub fn add(int x, int y) int
{
// use wait operator for waiting the result
return wait add_async(x, y);
}
The text was updated successfully, but these errors were encountered:
Code example demonstrates language capabilites
The text was updated successfully, but these errors were encountered: