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

Confusing example on script definition order

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

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

評価

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

調査の方向性

Issue にリンクされている scripts のドキュメントページから始め、定義順序の例と、スクリプト出力について周囲で説明されている内容を確認してください。呼び出しを移動したときに出力の違いが明確に説明されるよう、例を更新するか注記を追加してください。ドキュメントが定義順序を正確に示し、初心者に誤解を与えなければ完了です。

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

説明

Issue

I'm currently reading the book which claims that

there is no requirement that definitions have to come before the parts of the script that call the definitions [...]

while showing these scripts as examples of how definition order does not matter:

def greet [name] {
  ["hello" $name]
}

greet "world"
greet "world"

def greet [name] {
  ["hello" $name]
}

This choice of examples is a bit unfortunate in my opinion as, when running both scripts, they have different output.
My understanding is that this is caused by the last expression in a script being printed which evaluates to ["hello" "world"] and nothing respectively.
However, this confused me initially and I would expect this to trip up some other new users as well.

Possible improvements

  1. Changing the script to e.g.
def greet [name] {
  ["hello" $name]
}
greet "world" | null

or

def greet [name] {
  ["hello" $name]
}
let foo = greet "world"
$foo

would result in the same output when moving the command invocation line around but might raise other questions.

def greet [name] {
  ["hello" $name]
}
def greet-world [] {
  greet "world"
}
greet-world

and then moving the definition of greet-world to the top is probably the best example I can think of right now.

  1. Alternatively, the different output could be explained in a small note. I'm not even sure sure if the book explains the last expression of a script being printed up to that point. It's definitely explained in a note for functions but I don't remember reading that the same applies for scripts. I wouldn't rule out that I simply missed that part, though.
主要言語
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 を短くまとめたダイジェスト。