why compiler try use my sqrt not std.math?

Cym13 cpicard at purrfect.fr
Wed May 8 09:29:39 UTC 2019


On Wednesday, 8 May 2019 at 09:20:35 UTC, KnightMare wrote:
> 2) why
> (string s) { return cast( int )s.length; } typeof is int 
> delegate( string )
> but
> (string s) => { return cast( int )s.length; } typeof is int 
> delegate() delegate( string )


That I can answer:

   (string s) => { return cast( int )s.length; }

is equivalent to

   (string s) => (){ return cast( int )s.length; }

since empty parens can be ommited.

So it's a delegate that returns a delegate. Don't put {} there.

The equivalent with => will be:

   (string s) => cast( int )s.length


More information about the Digitalmars-d mailing list