Delegate parameter name shadows type name

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 9 11:51:12 PST 2017


On 01/09/2017 11:23 AM, H. S. Teoh via Digitalmars-d-learn wrote:
 > On Mon, Jan 09, 2017 at 11:18:02AM -0800, Ali Çehreli via 
Digitalmars-d-learn wrote:

 >> // Some function of the API that takes a delegate
 >> void call(void delegate(MyType) dlg) {

That's a delegate type.

 >>     call(delegate void(MyType) {
 >
 > Are you sure this isn't spelt `void delegate(MyType)`?

Those two syntaxes always confuse me and I'm never sure without trying 
which one to use when. :) However, the code is correct in this case 
because that's a delegate instance.

Ali



More information about the Digitalmars-d-learn mailing list