https://kotlinlang.org logo
#announcements
Title
# announcements
g

grahamborland

03/08/2017, 11:17 AM
Is this still the nicest (or only) syntax for multiple annotations on a field?
Copy code
@field:[Inject Named("ActiveBudgetId")] internal lateinit var activeBudgetId: String
Not quite as nice as the Java equivalent
Copy code
@Inject @Named("ActiveBudgetId") String activeBudgetId;
o

okkero

03/08/2017, 2:19 PM
grahamborland: Have you tried
@field:Inject @field:Named("ActiveBudgedId")
?
g

grahamborland

03/08/2017, 2:25 PM
Ah, that works. Also, just
@Inject @field:Named(”ActiveBudgetId”)
works nicely as well. Thanks!
o

okkero

03/08/2017, 2:29 PM
yep
I'm not entirely sure about the rules, but I think if an annotation could only possibly have one target within the given context, you don't need to specify the target (@field:)
2 Views