Function Definition
Define a function using the fn keyword.
fn greet(name) {
pt("Hello, " + name + "!")
}
greet("Zaky")
Anonymous Functions (Arrow Syntax)
dryLang does not support traditional anonymous functions (like fn() {}). Instead, we strictly enforce "one way to do things" using Arrow Functions (->).
// Single parameter
double = x -> x * 2
// Multiple parameters
add = (a, b) -> a + b
// Block body
complex_math = (x, y) -> {
z = x + y
rev z * 2
}
Returning Values
Use rev to return a value from a function.
fn add(a, b) {
rev a + b
}
result = add(10, 20)
pt(result) // 30
Async Functions
Use asn fn to declare an async function, and awt to await it.
asn fn fetchData() {
rev req("https://api.example.com")
}
data = awt fetchData()