mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 02:01:54 +03:00
add example for static constant
This commit is contained in:
parent
5654e8a7a6
commit
a34f36b9c1
@ -64,6 +64,23 @@ let x = u8::MAX; // A constant value on the scalar type
|
|||||||
let y = u8::to_bits(1u8); // A static method on the scalar type
|
let y = u8::to_bits(1u8); // A static method on the scalar type
|
||||||
```
|
```
|
||||||
|
|
||||||
|
It also allows for static constants for circuits in general:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
circuit Point {
|
||||||
|
static SLOPE: u32 = 3;
|
||||||
|
x: u32;
|
||||||
|
y: u32;
|
||||||
|
|
||||||
|
function new(x: u32, y: u32) -> Self {
|
||||||
|
return Self {
|
||||||
|
x,
|
||||||
|
y: y + Self::SLOPE
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Drawbacks
|
## Drawbacks
|
||||||
|
|
||||||
This change adds more complexity to the language.
|
This change adds more complexity to the language.
|
||||||
|
Loading…
Reference in New Issue
Block a user