Variable Shadowing: "Let" Keyword Is Immutable But Not Constant Variableby@wagslane
126 reads

Variable Shadowing: "Let" Keyword Is Immutable But Not Constant Variable

by Lane Wagner3mAugust 19th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Rust is strongly typed and defaults to immutable values. By default new variables are immutable, which means they can't be reassigned. In Rust, "let" declares immutable values, which contributes to Rust being a safer language. We will learn how immutable!= constant by using variable shadowing. In JavaScript, the let keyword is used to declare mutable values, but in Rust, it is allowed to declare a new variable with the same name, even all in the same scope. The name of the variable can easily point to an entirely new variable.

Company Mentioned

Mention Thumbnail
featured image - Variable Shadowing: "Let" Keyword Is Immutable But Not Constant Variable
Lane Wagner HackerNoon profile picture
Lane Wagner

Lane Wagner

@wagslane

Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

About @wagslane
LEARN MORE ABOUT @WAGSLANE'S
EXPERTISE AND PLACE ON THE INTERNET.

Share Your Thoughts

About Author

Lane Wagner HackerNoon profile picture
Lane Wagner@wagslane
Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here
L O A D I N G
. . . comments & more!