nushell.github.io icon indicating copy to clipboard operation
nushell.github.io copied to clipboard

Documentation for variables appears incorrect

Open kneutron opened this issue 1 year ago • 1 comments

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

kneutron avatar Apr 12 '23 15:04 kneutron

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.

fdncred avatar Apr 12 '23 16:04 fdncred

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.

Kissaki avatar May 29 '24 21:05 Kissaki

thanks

fdncred avatar May 29 '24 21:05 fdncred