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
  • There are two types of scope variable bindings in Gauntlet:
  • 1. let-variables
  • 2. zero-variables
  • Working Example
Export as PDF

Scope Variables

PreviousFile Setup & Hello WorldNextConstants

Last updated 4 days ago

There are two types of scope variable bindings in Gauntlet:

Both types of variables are mutable

For syntax of varPattern see

1. let-variables

let-variables use the := operator under the hood. It's syntax is:

let [TypeName] <varPattern> = <expression>

2. zero-variables

Zero-variables create an instance of a type's "zero" value. In Gauntlet, the syntax is:

zero <TypeName> <varPattern>

Working Example

package main

import "fmt" as fmt

fun Unit main() {
  let Int a, b, c = (1, 2, 3)
  let myName = "Bobby"
  fmt.println(myName)

  zero Int myZeroVar
  fmt.println("The number below should be 0, since it's Int's 'zero' value:")
  fmt.println(myZeroVar)
}
package main

import fmt "fmt"

func main() {
	var a, b, c int = 1, 2, 3
	myName := "Bobby"
	fmt.Println(myName)
	var myZeroVar int
	fmt.Println("The number below should be 0, since it's Int's 'zero' value:")
	fmt.Println(myZeroVar)
	// Eliminates any 'unused variable' errors
	_, _, _, _, _ = a, b, c, myName, myZeroVar

}
Bobby
The number below should be 0, since it's Int's 'zero' value:
0

πŸ” 
Common placeholders throughout documentation