Sign In / Up
  • 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
}

Lesson discussion

Swap insights and ask questions about “Learn everything about Move on Sui”.

Be the first to start the discussion

Ask a question or share your thoughts about this lesson.