| Thread overview | |||||
|---|---|---|---|---|---|
|
January 30, 2012 combine different data type | ||||
|---|---|---|---|---|
| ||||
when i do that auto x = [1, "ha"];
i have an error Error: incompatible types for ((1) ? ("hgh")): 'int' and 'string'
if there any method to combine different data type?
| ||||
January 30, 2012 Re: combine different data type | ||||
|---|---|---|---|---|
| ||||
Posted in reply to sami | On Mon, 30 Jan 2012 13:58:38 +0100, sami <sami@hotmail.com> wrote:
> when i do that auto x = [1, "ha"];
> i have an error Error: incompatible types for ((1) ? ("hgh")): 'int' and 'string'
> if there any method to combine different data type?
You might want to check out std.variant. It's Variant type can hold any
type you may want.
| |||
January 30, 2012 Re: combine different data type | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | "Simen Kjærås" <simen.kjaras@gmail.com> wrote in message news:op.v8wj38qf0gpyof@biotronic.lan... > On Mon, 30 Jan 2012 13:58:38 +0100, sami <sami@hotmail.com> wrote: > >> when i do that auto x = [1, "ha"]; >> i have an error Error: incompatible types for ((1) ? ("hgh")): 'int' and >> 'string' >> if there any method to combine different data type? > > You might want to check out std.variant. It's Variant type can hold any type you may want. Or std.typecons.tuple. It will allow you to have a collection of values of different types. It deptends what your use case it. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply