void
A return contract with no produced value.
These examples describe the Development language contract. They are not a claim that every workflow is supported by the current public preview. Declaration excerpts belong inside a function unless a full module is shown.
Meaning
void means that an operation produces no value. It does not have a numeric range or a constructible ordinary scalar value. It differs from never: a void function may return normally. Do not use void as an ordinary variable, field or parameter value type.
fn Touch() -> void {
return;
}Calls and control flow
Call a void function as a statement for its effects. Assignment is also void-valued in Sn, so it is not a C-style value-producing expression.
fn SetFlag(Flag: mut bool&) -> void {
Flag = true;
}
fn Main() -> i32 {
var Flag: bool = false;
SetFlag(Flag);
return 0;
}Result contracts
A documented generic API may use void to express success without a payload, such as Result<void, E>. That does not create an ordinary void value; follow the API’s no-payload success case.
from std.io import TryPrint;
fn Main() -> i32 {
switch TryPrint("Hello\n") {
case .Ok => return 0;
case .Err { Error = _ } => return 1;
}
}See all primitive types and literals and user-defined suffixes.