SplitScript reference / Language / callable type
callable type
syntax
(Parameter, ...) -> Result
Describes a first-class callable value.
The parameter list may be empty and the result may be any ordinary type, including async T. A value of this type is invoked with ordinary call syntax. Both named fn values and closure expressions infer this type from either direction and share one runtime representation. Merely storing either kind of callable does not execute its effects. Callable values are intentionally not Equatable.
Examples
Accept a callable value
fn apply(value: u32, transform: (u32) -> u32) -> u32 {
return transform(value)
}
Store a named function
fn increment(value: u32) -> u32 {
return value + 1
}
let later = increment
print(later(4))