Wish Inline Dim

Troberg

Well-Known Member
Licensed User
Longtime User
I very often find myself writing code such as:

Code: Copy
Dim n as int
For n=0 to 100
  'Do stuff
Next

Now, some languages have a neat construct which saves a mostly unnecessary line. In Basic, it would be something like:

Code: Copy
For n as int=0 to 100
   'Do stuff
Next

Basically, an inline Dim where the variable is dimmed on first use. Somewhat like an even shorter form of:

Code: Copy
Dim x as int = 0

as a substitute for:

Code: Copy
Dim x as int
x=0

Personally, I wouldn't use it on important or complex variables, but for trivial ones like in the example, it's very practical.
 
You don't need to call dim here at all.
A for loop automatically declares an int value (if it is not already declared).
And it is working like that from the first version I bought 1.8 (year 2012) :)
 
Back
Top