Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created October 14, 2025 11:39
Show Gist options
  • Save JoeGlines/e4775e30f6cd569f507ed49304c7efb6 to your computer and use it in GitHub Desktop.
Save JoeGlines/e4775e30f6cd569f507ed49304c7efb6 to your computer and use it in GitHub Desktop.
#Requires AutoHotkey v2.0.2+
#SingleInstance Force
; Regular function
greetUser(name) {
return "Hello, " . name
}
; Function that takes a function as parameter
applyOperation(x, y, operationFunc) {
return operationFunc(x, y)
}
; Call the functions
message := greetUser("Alice")
MsgBox(message)
; Anonymous function stored in variable
addFunc := (a, b) => a + b
result := applyOperation(5, 3, addFunc)
MsgBox(result) ; 8
; Inline anonymous function
result2 := applyOperation(5, 3, (a, b) => a * b)
MsgBox(result2) ; 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment