A D vs. Rust example

jmh530 john.michael.hall at gmail.com
Thu Oct 20 14:09:23 UTC 2022


On Thursday, 20 October 2022 at 13:37:07 UTC, Don Allen wrote:
> [snip]
> The D equivalent:
> ````
> import std.stdio;
>
> void main()
> {
>     int foo;
>     void bar() {
>         foo = 17;
>     }
>     void baz() {
>         foo = 42;
>     }
>     bar();
>     writeln(foo);
>     baz();
>     writeln(foo);
> }
> ````
>[snip]

TIL that this works...I thought it would only work for 
global/static variables.


More information about the Digitalmars-d mailing list