Add result tuple assert

This commit is contained in:
Scott Richmond 2023-12-18 01:06:09 -05:00
parent a86b8f4fa4
commit 2fbf82f8ab

View File

@ -903,6 +903,13 @@ fn assert! {
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
& some basic colors
@ -1282,6 +1289,7 @@ ns prelude {
unwrap!
unwrap_or
assert!
assert
colors
forward!, fd!
back!, bk!