Functions With No Arguments And No Return Value
The formula for functions that take no arguments and return no values is:
- The
fn
keyword - A name
- An empty set of
()
parenthesis - A set of
{}
curly brackets surrounding the function's code block
For example:
fn widget() {
println!("this is widget");
}
Calling functions without arguments is done using its
name followed by empty ()
, like:
widget();