A Discussion of Tuple Syntax
bearophile
bearophileHUGS at lycos.com
Mon Aug 19 12:54:42 PDT 2013
Meta:
> It *could* be an underscore; the only thing is that the
> underscore is a valid variable name, so the above expression
> would actually be binding two variables, which might surprise
> someone who was expecting otherwise. I don't really care all
> that much, but it's something to think about.
You can't define a variable more than once in a scope, so this
can't be valid:
void main() {
auto t1 = #(5, "hello", 1.5);
auto (_, _, x) = t1;
auto (_, gr, _) = t1;
}
While ? defines nothing, so this is OK:
void main() {
auto t1 = #(5, "hello", 1.5);
auto (?, ?, x) = t1;
auto (?, gr, ?) = t1;
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list