Confusing example on script definition order
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- documentation
Direzione di ricerca
Inizia dalla pagina della documentazione di scripts collegata nell’issue e rivedi gli esempi sull’ordine delle definizioni insieme alla spiegazione circostante dell’output dello script. Aggiorna l’esempio oppure aggiungi una nota, in modo che la differenza nell’output sia spiegata chiaramente quando viene spostata l’invocazione. Il lavoro è completato quando la documentazione dimostra accuratamente l’ordine delle definizioni senza trarre in inganno chi è alle prime armi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 258
- Fork
- 561
- Merge medio
- 3h 20m
- PR unite (30g)
- 15
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nushell/nushell.github.io
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
nushell/nushell.github.io#2081 · 3 commenti ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
nushell/nushell.github.io#767 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
nushell/nushell.github.io#2232 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
nushell/nushell.github.io#2209 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
nushell/nushell.github.io#2194 ·
Tutte le issue di nushell/nushell.github.io
Issue simili
-
blocklist removal
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MetaMask/eth-phishing-detect#296544 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pastelsky/bundlephobia#1122 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100