Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Are Boolean operators lazy?

オープン
#2,072 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
48/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
shell
領域
documentation

調査の方向性

リンクされている Boolean のドキュメントページと、参照されている Nushell の issue 10237 から始めてください。and と or が遅延評価されることが保証されているかを確認し、その後、確認できた動作と、適切な Boolean のドキュメントページにある示された例への影響を文書化してください。

索引モデルが issue の本文から書いたものです。

説明

Hello,

TL;DR: Are the and and or Boolean operators guaranteed to be lazy, so we can document it?


I encountered this bug https://github.com/nushell/nushell/issues/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?

主要言語
TypeScript
スター
258
フォーク
561
平均マージ
3時間 20分
マージ済み PR(30日)
15

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nushell/nushell.github.io のほかの issue

nushell/nushell.github.io の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。