Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

ContributingCommunityRepository

Get Started

InstallationGetting StartedCLI

Language

SyntaxTypesFunctionsStructsGenericsPattern MatchingError HandlingModulesTesting

Project

Code StyleContributing

Language

Functions

Tea supports named functions, typed parameters, explicit return types, locals, and lambdas.

Functions in Tea are declared with def. Parameters and return types are explicit, which keeps call sites easy to read and makes public APIs predictable.

Named functions

A named function declares its parameters up front, returns a value with return, and closes with end. This is the form you will use for most reusable program logic.

def add(a: Int, b: Int) -> Int
  return a + b
end

const total = add(1, 2)
@println(total)

Functions can also return early when a branch should stop execution immediately.

def describe(score: Int) -> String
  if score >= 90
    return "excellent"
  end

  return "keep going"
end

Lambdas and closures

Use lambdas for short pieces of behavior you want to pass around or return from another function. They use the |args| => expr form and can capture values from the surrounding scope.

def make_adder(base: Int) -> Func(Int) -> Int
  return |value: Int| => base + value
end

const add_two = make_adder(2)
@println(add_two(5))

What is stable today

  • Named def declarations with typed parameters and returns.
  • return inside functions when you want early exits.
  • Lambdas with |args| => expr syntax.

  • Higher-order code via Func(...) -> ... signatures.

Next steps

Continue to

Error Handling

See how functions declare thrown errors.

Continue to

Modules

Export public functions with `pub`.