Why is this allowed

psycha0s box at mail.com
Wed Jul 1 12:41:06 UTC 2020


On Tuesday, 30 June 2020 at 16:22:57 UTC, JN wrote:
> Why does such code compile? I don't think this should be 
> permitted, because it's easy to make a mistake (when you wanted 
> foo[index] but forgot the []). If someone wants to assign a 
> value to every element they could do foo[] = 5; instead which 
> is explicit.

Totally agree. In most of cases implicit actions lead to errors. 
Even if they have a specific use case and really convenient.


More information about the Digitalmars-d-learn mailing list