let (x,y) = ...

thedeemon via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Nov 23 10:38:44 PST 2015


On Monday, 23 November 2015 at 16:58:43 UTC, Andrea Fontana wrote:
> Nice. Why first enforce is "==" rather than ">=" ? This 
> prevents something like:
> auto arr = ["hello", "world", "!"];
> let (hello, world) = arr;

The very first post of this thread should have answered this.
Two options are available: one requires exact number of elements 
and so catches more errors, the other requires there to be 
"enough" data, for cases where you want that. To get behavior you 
described just use

let (hello, world)[] = arr;




More information about the Digitalmars-d-announce mailing list