1 May 2007 22:24
Re: Still annotations
Hi Nikolay,
Thank you for the fix. I think the mentioned web page could serve an example for the usage of arrays as parameters.
As I see in the <at> throws annotation, it does not allow Arrays for values. Is this mean, that the annotations may be multiple times from the same type at the same position? (I think it would be more natural if <at> throws accept array of classes.)
Best regards, gabor
2007/4/27, Nikolay Mihaylov <nikolay.mihaylov-p8DiymsW2f8@public.gmane.org>:
Hi Gabor,
You hit the right syntax but you also hit a bug in the compiler which
must have appeared when we changed the way array values are
constructed. It is now fixed in the repository and will be part of
the next release. Until then there's no way to use arrays in
annotations. Sorry for the inconvenience.
BTW, the syntax for annotation application is more flexible. For
instance, in your case one could write <at> SuppressWarnings(Array
("unused")). Note that (1) you never need to write the type of the
Array and (2) for Java annotations the constructor parameter is the
annotation attribute with the name 'value'. Also, if you have empty
constructor argument list you need not write the empty parentheses, i.e.
<at> SuppressWarnings{val value = Array("unused")}
instead of
<at> SuppressWarnings(){val value = Array("unused"))}
For more details go to
http://www.scala-lang.org/intro/annotations.html
Greetings
Nikolay
> Hi all,
>
> I still could not find the solution to this newbie question...
> Could you tell me the proper syntax? (How can I set annotation
> values for fields expecting a constant array?)
> (From my previous post I have tried the following syntax too:
> <at> SuppressWarnings(){val value=Array[String]("unused")}.
> The compiler's response was:
> Severity and Description Path Resource Location
> Creation Time Id
> attribute argument needs to be a constant; found: scala.Array.apply
> [java.lang.String]("unused")
> )
> Best regards, gabor
>
RSS Feed