Suppose I have a variable x in a function; and I may set it to two possible values (depending on function computation paths). Once I set x, I do not change it.
Unfortunately, const requires x to be set at declaration.
Is there a way in an assignment x= val to say "from this point on, the value of x will not change"?
Hi , maybe the best option is just assign the computation value to a different temporary variable then intialize your x on declaration , am not sure if there is any other possible way, my idea here could still be viable.
Yeah that's legal but not enough our problem is yet to be solved, you notice in that case you'll be creating two local variables in different scopes, am sure they can't be accessed outside those blocks, so it's like they get created and then destroyed almost instantly.