I don’t quite understand the specific purpose of short assignments,
why do this:
x:= 10
when this is also possible:
var x = 10
Is there any specific use case where short assignments are more convenient
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the above case, the variables are confined within the if statement. If you try to access
erroutside of the if statement, it won’t be available. Likewise forx. There’s various cases where maintaining scope like this might be useful, but I’d say the use of:=is for given styles like the above withif,switch,for.For some additional background,
varalso allows grouping, much like usingimport.which pushes the use-cases for
varvs:=further apart.