Gauntlet Documentation
  • 🏠Welcome
  • πŸ…Getting Started
    • 🧠Introduction To Gauntlet
  • ‼️Read before Proceeding
  • ⬇️Installation
  • πŸ‘¨β€πŸ’»VSCode Extension
  • πŸ“šBasics
    • πŸ’¨Running Gauntlet
    • πŸ“„File Setup & Hello World
  • πŸ” Scope Variables
  • πŸ–ΌοΈConstants
  • 🧩Functions
  • ↔️If Statements
  • πŸ”‘Ternary Operator
  • πŸ’ Switch-Case
  • πŸ“©Select-Case
  • ➰Loops
  • πŸ“Structs
  • 🧱Interfaces
  • πŸͺͺAliases
  • πŸ“ŽMethods
  • πŸ¦™Lambdas
  • πŸ•ΈοΈMiscellaneous
  • ⚑Advanced Features
    • πŸ”€When-Cases
    • 🚰Pipes
    • ⁉️Try-Statements
    • 🎭Force-Statements
    • 🌯Wrapper Types
Powered by GitBook
On this page
  • Lambda Syntax
  • Working Example
Export as PDF

Lambdas

PreviousMethodsNextMiscellaneous

Last updated 7 days ago

Lambda Syntax

lambda <ReturnType> (Parameters) {
    <lambda body>
}

For syntax of Parameters -

Working Example

package main

import "fmt" as fmt


fun Unit main() {
  let myLambda = lambda String (Bool caps) {
    if caps {
      return "HELLO"
    }
    else {
      return "Hello"
    }
    
  }
  fmt.println(myLambda(true))
}
package main

import fmt "fmt"

func main() {
	myLambda := func(caps bool) string {
		if caps {

			return "HELLO"
		} else {

			return "Hello"
		}
	}
	fmt.Println(myLambda(true))
	// Eliminates any 'unused variable' errors
	_ = myLambda

}
HELLO

πŸ¦™
Common placeholders throughout documentation