Package and Imports
In Manul, a package is a directory containing source files. Every source file within a package must begin with a package declaration statement.
However, source files located at the root of the src directory belong to the root package and do not require a package declaration.
Directorysrc/
- user/ user.mnl
package user
class User( var name: string, var email: string)The qualified name of a class within a package follows the format {package-name}.{class-name}. To use a class from a different package, you must either reference it by its fully qualified name or use an import statement.
The following example demonstrates how to import and use the User class from the user package inside a product package:
package product
import user.User
class Product( var name: string, var price: double, val owner: User)