Previously variable declaration required a keyword, e.g. ```kcl let x = 4 const x = 4 var x = 4 ``` These were all valid, and did the exact same thing. As of this PR, they're all still valid, but the KCL formatter will change them all to just: ```kcl x = 4 ``` which is the new preferred way to declare a constant. But the formatter will remove the var/let/const keywords. Closes https://github.com/KittyCAD/modeling-app/issues/3985
38 lines
26 KiB
Markdown
38 lines
26 KiB
Markdown
---
|
|
title: "assert"
|
|
excerpt: "Check a value at runtime, and raise an error if the argument provided"
|
|
layout: manual
|
|
---
|
|
|
|
Check a value at runtime, and raise an error if the argument provided
|
|
|
|
is false.
|
|
|
|
```js
|
|
assert(data: bool, message: string) -> ()
|
|
```
|
|
|
|
|
|
### Arguments
|
|
|
|
| Name | Type | Description | Required |
|
|
|----------|------|-------------|----------|
|
|
| `data` | `bool` | | Yes |
|
|
| `message` | `string` | | Yes |
|
|
|
|
### Returns
|
|
|
|
`()`
|
|
|
|
|
|
### Examples
|
|
|
|
```js
|
|
myVar = true
|
|
assert(myVar, "should always be true")
|
|
```
|
|
|
|

|
|
|
|
|