how to expand tuple?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Nov 1 14:55:31 PDT 2014
On 11/01/2014 01:34 PM, Suliman wrote:
> Or auto mean structure of data, that have not standard type
> like (int or string)?
D is a strongly typed language, so every variable has its specific type.
D also has type inference, meaning that we don't need to specify types
explicitly. In theory, even the following could work:
t = tuple(42, 1.5);
and the type of t would be Tuple!(int, double). However, the syntax
rules require a keyword before t. If t could be either one of the
following, we could simply write:
const t = ...
immutable t = ...
shared t = ...
static t = ...
The problem is when t is not either one of those. In that case auto
comes to the rescue:
auto t = ...
Note that auto (meaning "automatic storage duration") is actually
redundant there but works well because it kind of means "infer the type
automatically." Hm. It is redundant even there because "infer" implies
"automatic" :p.
Ali
More information about the Digitalmars-d-learn
mailing list