double -> double[]... | feature or bug?

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Dec 22 12:46:01 PST 2010


I thought the variadic version would only take this type:

average([1.5], [2.5]);

So a variable number of *array* of doubles, not a variable number of doubles.

On 12/22/10, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> On Wednesday, December 22, 2010 12:05:18 Andrej Mitrovic wrote:
>> DMD 2.051 with -unittest:
>>
>> import std.algorithm, std.range, std.stdio : writeln;
>>
>> void main() {}
>>
>> void average(double[]) { writeln("non-variadic"); }
>> void average(double[]...) { writeln("variadic"); }
>>
>> unittest {
>>     average(1.5);   // writes "variadic"
>> }
>
> What's the confusion? You gave it a double. That matches the variadic
> version,
> no tthe array version. If you gave it an array of doubles, then it would
> match
> the array version. That seems entirely straightforward. What's surprising
> about
> it?
>
> - Jonathan M Davis
>


More information about the Digitalmars-d-learn mailing list