Search

February 28, 2011
General »
How are these better than

foo(/*width*/ 10, /*height*/ 20);

? One advantage of named parameter...
February 28, 2011
General »
...said if you're passing around the width and height much (as opposed to just...
February 28, 2011
General »
...better:

struct _(string s) { int data; alias data this; }

foo(_!"width"(10), _!"height"(20));

-- 
Simen
February 28, 2011
General »
...void foo(int width, int height);

auto args = NamedParameterTypeTuple!(foo);

args.width = 10;
args.height...
February 28, 2011
General »
...quite specific:


"width :123" breaks an English rule for no purpose, and "width:123" is...
February 28, 2011
General »
...no reason to write "width: 123" rather than "width:123" or "width : 123". Rather the...
February 28, 2011
General »
...resize(Size size)
{
     if (size.width)
         this.width = size.width;
     if (size.height)
         this.height...
February 28, 2011
General »
...void resize(int width=0, int height=0)
{
    if (width)
        // set new width
    if (height...
February 28, 2011
General »
...I could also do:

int width = 10, height = 20;
foo(width, height);

The struct solution...
February 28, 2011
General »
...their own struct...

struct Width { int width; alias width this; }

foo(Width(10), Height(20));
113 114 115 116 117 118 119 120 121 122 123
Next ›   Last »