Any way to define variables from one scope in another scope?

bauss jj_1337 at live.dk
Tue Jun 21 12:53:55 UTC 2022


On Monday, 20 June 2022 at 13:56:04 UTC, Ruby The Roobster wrote:
> Is there any way to define variables in an outer scope from an 
> inner scope?  I was thinking
>
> ```d
> void main()
> {
>     int .y = 3;
> }
> ```
> would work, but it doesn't.

No and it would only lead to bugs.

If you have access to an inner scope then surely you have access 
to the outer scope and can just add the variable there.

If you need to add a variable in a nested scope, then surely 
you're solving a problem with the wrong solution.


More information about the Digitalmars-d-learn mailing list