Hello, here is example code, which doesn't work:
Variant[] vtypes = [ Variant("hello"), Variant("bye") ];
string[] filetypes = map!(to!string)(vtypes);
Gives me error:
Error: cannot implicitly convert expression (map(vtypes)) of type
MapResult!(to, VariantN!(24u)[]) to string[]
On Tue, Dec 10, 2013 at 6:54 AM, Dfr wrote:
> Hello, here is example code, which doesn't work:
>
> Variant[] vtypes = [ Variant("hello"), Variant("bye") ];
> string[] filetypes = map!(to!string)(vtypes);
>
> Gives me error:
>
> Error: cannot implicitly convert expression (map(vtypes)) of t
Thank you for good explanation.
But i currently hit little more complex case and again stuck,
maybe some ideas how to resolve this, unfortunately compiler
messages not very explanatory.
void main()
{
Variant[] lols = [ Variant(["hello": Variant(1)]),
Variant(["bye": Variant(true)]) ];
Dfr:
auto vtypes = map!(to!Variant[string])(lols);
The short template instantiation syntax only supports a single
token, to avoid mistakes,so you need to add ():
map!(to!(Variant[string]))(lols);
That is better written:
lols.map!(to!(Variant[string]));
But I don't know if this is eno
> void main()
> {
> Variant[] lols = [ Variant(["hello": Variant(1)]), Variant(["bye":
> Variant(true)]) ];
> auto vtypes = map!(to!Variant[string])(lols); // <--- line 11
>
> string[] filetypes = map!(to!string)(vtypes).array();
> writeln(filetypes);
> }
>
> Gives me:
> main.d(11)
Thank you, this clears thing to me.
I currently has all stuff wrapped in Variants because it is
structure parsed from xml (or json), and it could be for example
map of Something[string], where Something could be string or
array or another map, and also this all nested few levels deep.
I'm ne
On Wed, Dec 11, 2013 at 7:26 AM, Dfr wrote:
>
> Thank you, this clears thing to me.
>
> I currently has all stuff wrapped in Variants because it is structure parsed
> from xml (or json), and it could be for example map of Something[string],
> where Something could be string or array or another map