-
Notifications
You must be signed in to change notification settings - Fork 537
Open
Description
Hello,
TL;DR: Are the and and or Boolean operators guaranteed to be lazy, so we can document it?
I encountered this bug nushell/nushell#10237 which makes last error out on an empty input instead of returning a null if I understand correctly.
So I have written this workaround:
let filler = if ($text != "") and ($text | split chars | last) == "%" { "%" } else { " " }This code works without errors for me, so the RHS of the and Boolean operator must not be evaluated / be lazily evaluated.
To put it short, the and operator seems lazy (nu version 0.108.0)
I cannot find it documented in Boolean | Nushell and looking for "lazy" in the documentation does not yield anything related to Booleans.
Is and guaranteed to be lazy in future versions? What about or?
Should we document this behavior?
Metadata
Metadata
Assignees
Labels
No labels