Skip to content

Multiple Source Files

When you create a project, you can see the main.cb file. You can also create more files ending in .cb and they’ll get run automatically in alphabetical order.

This means that if I have this file structure:

Terminal window
MyProject/
├─ src/
├─ main.cb
├─ hello.cb
└─ cranberry.toml
println("Hello")
println("Main")

Main will always be printed after Hello since main.cb is ran last.

But that also means anything you define in other files can be accessed through main.cb. (Such as defining a class in a separate script and using it in the main file.)

How can I separate files effectively? Well thats where Namespaces come in…