I see following code on this page:
int main(string[]@a)
{print("Manganese");return 0;}
Why it is not following:
int main(string[] args)
{print("Manganese");return 0;}
What is difference between string[]@a
and string[] args
and when is it used?
The @
symbol is used to prefix identifier names when the name either begins with a digit, or is a keyword.
Identifier names may be any combination of letters ([a-z], [A-Z]), underscores and digits. However, to define or refer to an identifier with a name that either starts with a digit or is a keyword, you must prefix it with the '@' character. This character is not considered a part of the name. For example, you can name a method foreach by writing @foreach, even though this is a reserved Vala keyword. You can omit the '@' character when it can be unambiguously interpreted as an identifier name, such as in "foo.foreach()".
See: Vala Tutorial under the Syntax section
To answer your question "What is difference between string[]@a
and string[] args
and when is it used?", well, not much. Other than simply using the variable name a
instead of args
, it's not a compiler error to use the @
symbol in front of other variable names, even when the criteria above aren't met (although certainly not good practice). The author could safely prefix the variable a
as @a
, even though it's not the normal usage of the prefix.