Pages
Introduction
Getting Started
Recipes
Reference
Literals
Arrays
Tuples
Type System
Functions
Modules
Records
Enums
Built-in Types
Constants
Equality
Stores
Routing
Comments
Control Expressions
Components
Properties
Computed Properties
Styling Elements
Connecting Stores
Using Providers
Internal State
Referencing Entities
Global Components
Lifecycle Functions
Directives
JavaScript Interop
Environment Variables
Packages
Modules
In Mint modules are kind of containers for a set of relatable functions. They are usually used to gather functions that relate to a specific type (like
String
or
Number
).
module Greeter {
fun greet (name : String) : String {
"Hello #{name}!"
}
}
You can call the functions of a module by using the modules name:
Greeter.greet("Joe") /* "Hello Joe" */
You can omit the name of the module if you are calling a function from an other function in the same module:
module Greeter {
fun greet (name : String) : String {
"Hello #{name}!"
}
fun greetUpperCase (name : String) : String {
name
|> String.toUpperCase()
|> greet
}
}