On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote:
On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote:
Is it possible to create such an array in which you can store
strings and numbers at the same time?
string-int[] array = [4, "five"];
using an array of tuple it works:
----
import std.stdio;
import std.typecons;
alias T = Tuple!(string, int);
void main(string[] args)
{
T[] tarr;
tarr ~= T("a",65);
tarr ~= T("b",66);
writeln(tarr);
}
----
[Tuple!(string, int)("a", 65), Tuple!(string, int)("b", 66)]
mmmh maybe off-topic, you probably don't what pairs but either a
string representing an int or an int, do you ?
If so then an array of union ?