Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Assignments

Whenever you use a more complex expression, it is often useful to store it behind a name so that it can be used once or multiple times elsewhere.

In µcad, stored values are always immutable, meaning that once a value has been stored behind a name, it cannot be reset in the same context. This is different from the variables known in other programming languages.

test

use std::math::sqrt;

a = 2cm;
b = 5cm;
c = sqrt(a * a + b * b);

std::print("{c}");

[!TIP] If a name starts with an underscore (like _this_name) that suppresses any warning about if it is not in use.

There are several kinds of assignments for different purposes. A property for example is always related to a workbench so it can only be defined within one. Here is a complete list of all assignment types available in µcad and where they can be defined (✅) and where they are prohibited (❌):

TargetKey-wordSource FileModuleBuilding CodeFunc-tionInitial-izationInitial-izers
Value-
Model-
Constantconst
Publicpub
Propertyprop
Model-