Compare commits

...

1 Commits

Author SHA1 Message Date
Scott Richmond
2fbf82f8ab Add result tuple assert 2023-12-18 01:06:09 -05:00

View File

@ -903,6 +903,13 @@ fn assert! {
else panic! string ("Assert failed: ", msg, " with ", value) else panic! string ("Assert failed: ", msg, " with ", value)
} }
fn assert {
"Asserts a condition. Returns a result tuple: `(:ok, value)` if the value is truthy, and `(:err, value)` if it is falsy. Or, give it an error message, and that's what'll be in the error tuple instead."
(value) -> if value then (:ok, value) else (:err, value)
(msg, value) -> if value then (:ok, value) else (:err, msg)
}
&&& Turtle & other graphics &&& Turtle & other graphics
& some basic colors & some basic colors
@ -1282,6 +1289,7 @@ ns prelude {
unwrap! unwrap!
unwrap_or unwrap_or
assert! assert!
assert
colors colors
forward!, fd! forward!, fd!
back!, bk! back!, bk!