Confusing example on script definition order
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #1208 来自 @Inveracity —— 已关闭,未合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 45/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
调研方向
从 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
- 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.
- 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
- 星标
- 260
- 派生
- 563
- 平均合并
- 4 小时 36 分钟
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nushell/nushell.github.io 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 68/100
nushell/nushell.github.io#2081 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 62/100
nushell/nushell.github.io#767 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 58/100
nushell/nushell.github.io#2232 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 58/100
nushell/nushell.github.io#2209 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
nushell/nushell.github.io#2194 ·
维护者通常 1 天内回复
查看 nushell/nushell.github.io 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
wardian-app/Wardian#1603 ·
维护者通常 1 天内回复
-
Sign the pledge未关闭
难度 1/5 1 小时以内 新手友好度 85/100
input-output-hk/devx-updates#168 ·
维护者通常 1 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
agent-ready area: config area: skills type: chore upstream: brain-kit
难度 1/5 1 小时以内 新手友好度 95/100
-
dev experience frontend good first issue
难度 2/5 1-3 小时 新手友好度 78/100
cuttle-cards/cuttle#1403 ·
维护者通常 1 天内回复