nushell.github.io
nushell.github.io copied to clipboard
Documentation for variables appears incorrect
Related https://github.com/nushell/nushell.github.io/issues/797
https://www.nushell.sh/book/variables_and_subexpressions.html#variables
" Variables in Nushell are immutable, that means that you cannot change its value after declaration. They can be shadowed in nested block, "
This is very confusing to a brand-new user, it literally does not meet the definition of a "variable" - that would be a "constant"?
On OSX nu 0.78.0, reassigning another value to the same variable works:
let tmp = 1 04/12/2023 10:37:00 AM ~/bin> let tmp = 2 04/12/2023 10:37:11 AM ~/bin> echo $tmp 04/12/2023 10:37:15 AM 2
let tmp = 2 + 1 04/12/2023 10:52:14 AM ~/bin> echo $tmp 04/12/2023 10:52:24 AM 3
I will be learning nushell and I can help with updating documentation, please feel free to contact me if you are with the nushell project phuckad @ duck . com
it literally does not meet the definition of a "variable"
agreed. some variables are not variable.
back in nushell history, they were all immutable. today, some can be mutated with the mut
declaration. they can also be shadowed, which is what you've found out and are calling "reassigning". I, myself, coming from c/c++/c#, found immutability to be odd behavior too. however, i've come to learn that it's common in some functional programming languages.
help with docs would be great.
As commented in #797 - that page no longer exists, and there is no such text anymore. This ticket is outdated and can safely be closed.
thanks