function and variable

Fyodor Ustinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 9 19:28:46 PST 2015


Hi!

I think this code should not be compiled without any warning:

import std.stdio;

void f(int a) {
     writeln("it's a function! : ", a);
}

void main() {
     auto f = function (int a) {writeln("It's a variable! : ", 
a);};
     5.f();
     f(5);
}

Output:

it's a function! : 5
It's a variable! : 5

WBR,
     Fyodor.


More information about the Digitalmars-d-learn mailing list