Move on Sui Course
Init Function
- It is used to initialize a specific state of the application before any other code runs.
- It returns nothing.
- It can be defined multiple times in a package.
- The order of execution of the init functions depends on the order of their declaration in the code.
Here is an example of an init function in Sui:
// This is an init function that sets the value of a global variable to 42
init {
let x = 42; // This is a local variable
Global::set(x); // This is a function call that sets the global variable to x
}
Comments
You need to enroll in the course to be able to comment!