Auto keyword and when to use it
XavierAP
n3minis-git at yahoo.es
Wed Aug 22 09:04:02 UTC 2018
On Tuesday, 21 August 2018 at 21:37:00 UTC, QueenSvetlana wrote:
>
> I had a misunderstanding about the keyword auto because I
> wrongfully believed that it made the code like Python
Exactly, you are thinking still like D is Python or also
dynamically typed. :) You will get when compiling errors that
Python wouldn't detect until run-time (or with your private
methods).
- A declaration with auto needs to include an initialization.
- The code will be equivalent as if replacing "auto" with the
inferred type. It is not left for later to check.
I'm not terribly bothered btw by "Type = new Type()" but often
type names get too long or include namespaces...
"mylib.numeric.squareObjectWithPointyCorners = new
mylib.numeric.squareObjectWithPointyCorners()"
More information about the Digitalmars-d-learn
mailing list