Move Basics
This chapter covers the foundations of the Move language: the syntax, the type system, and the concepts that every Move program is built from. It focuses on the language itself and mostly sets the blockchain aside - everything here applies to any Move program, and the features specific to storage and Sui are covered right after, starting with the Object Model chapter.
The sections build on one another and are meant to be read in order:
- How code is organized: modules, comments, primitive types, the address type, expressions, and functions.
- Defining custom types: structs, and the ability system that controls what values of a type can do - starting with drop.
- Reusing existing code: imports and the Standard Library with its core types - vector, Option, and String.
- Writing logic: control flow, enums with pattern matching, struct methods, and visibility modifiers.
- The core of Move's safety story: ownership and scope, the copy ability, constants and aborting execution, and references.
- Abstraction tools: generics, macro functions, internal permits, type reflection, and, finally, testing.
Every code sample in this chapter comes from a compiling, tested package. Most samples are excerpts placed inside test functions, so you can copy any of them into the package created in the Hello World chapter and run them with sui move test.