Auto keyword and when to use it
QueenSvetlana
svetlanalilyrosemond at gmail.com
Mon Aug 20 17:24:19 UTC 2018
I'm new to D programming, but have I have a background with
Python.
I'm struggling to understand what the auto keyword is for and
it's appropriate uses. From research, it seems to share the same
capabilities as the var keyword in C#. From the C# documentation,
it states:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var
... variables that are declared at method scope can have an
implicit "type" var. An implicitly typed local variable is
strongly typed just as if you had declared the type yourself, but
the compiler determines the type.
Is the same true for auto? For example, if I have a class Person,
I might have attributes such as FirstName, LastName which should
obviously be strings but will D allow me to declare class level
attributes with auto?
C# doesn't allow this.
More information about the Digitalmars-d-learn
mailing list