endsWith - for a string vs an array of strings

Mengu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 11 23:49:15 PST 2015


On Saturday, 10 January 2015 at 23:32:47 UTC, bearophile wrote:
> Laeeth Isharc:
>
>>> In D there is a feature that allows a function to accept both 
>>> an array of items and items,
>
>> yes - it is funny there is not an overloading that accepts 
>> arrays
>
> I meant this D feature:
>
>
> void foo(T)(T[] items...) {
>     import std.stdio;
>     items.writeln;
> }
> void main() {
>     foo("red", "green", "blue");
>     foo(["red", "green", "blue"]);
>     auto a = ["red", "green", "blue"];
>     foo(a);
> }
>
>
> Bye,
> bearophile

for the curious, expanding tuples and typetuples on ali's book is 
explained at 
http://ddili.org/ders/d.en/tuples.html#ix_tuples..expand and at 
http://ddili.org/ders/d.en/tuples.html#ix_tuples.TypeTuple, 
std.typetuple.


More information about the Digitalmars-d-learn mailing list