AutoIt+
  • Overview
  • Getting started
  • The language
    • Basic
    • Grammar
      • Expressions
      • Statements
      • Declarations
    • Operators
    • Variables
    • Types & values
      • Null
      • Booleans
      • Numbers
      • Strings
      • Functions
      • Classes
      • Pointers
    • Control flow
      • If statement
      • For loop
      • While loop
      • Break & continue
      • Error handling
    • Collections
      • Array
        • APIs
        • Implementation
      • Map
        • APIs
        • Implementation
    • Modules
    • Exceptions
  • Built-in modules
    • C
      • APIs
      • Constants
    • Math
      • APIs
      • Constants
    • Task
      • Types
      • APIs
    • Global
  • The aup
    • Compiler
    • Runtime
    • Options
Powered by GitBook
On this page
  • Declare a function
  • Arrow functions (lambda)
  • Closures & bindings

Was this helpful?

  1. The language
  2. Types & values

Functions

Declare a function

Arrow functions (lambda)

Like JavaScript or C#, but our functions have no "this", so arrow function is a short way to create a function.

var add = (a, b) => a + b
puts add(4, 5)    // 9

Summary:

  • func keyword helps you declare a function in top-level of code.

  • Arrow function creates a function as an expression.

Closures & bindings

We have an example, a counting program:

var count = 0

func increase() {
    count++
}

func decrease() {
    count--
}

The count variable is binded in two functions, increase() and decrease(). When we call one of them, the value of count will be modified.

PreviousStringsNextClasses

Last updated 3 years ago

Was this helpful?