www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How does this work?

reply "Freddy" <Hexagonalstar64 gmail.com> writes:
I know what this does, but can someone explain how it works?
----
static if((typeof((inout int=0){

})));
----
Nov 23 2014
parent ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sun, 23 Nov 2014 22:51:48 +0000
Freddy via Digitalmars-d-learn <digitalmars-d-learn puremagic.com>
wrote:

 I know what this does, but can someone explain how it works?
 ----
 static if((typeof((inout int=3D0){
=20
 })));
 ----
it was here somewhere. this is, as you can see, a lambda. `typeof()` can be used even for invalid code and will return special `error` type (don't try to catch it, just trust me ;-). in `static if` this `error` type means `false`. labmda that can not be compiled is obvious invalid, uncompilable code, so it has a type of `error`. and `inout` is a hack for some kind of functions/templates. to make a long story short: don't try to remember it all, you'll forget it next day. just take it as it is and be happy. ;-)
Nov 23 2014