在Kotlin中使用@Annotation和[Annotation]有什么区别?

时间:2018-01-09 13:04:37

标签: annotations kotlin

例如

{{1}}

我在官方文档中没有找到任何内容。

2 个答案:

答案 0 :(得分:3)

Kotlin的早期预览版本支持9.41 min 93.2% 0 s _dispatch_workloop_worker_thread$VARIANT$mp 0x109890 9.41 min 93.2% 0 s _pthread_wqthread 9.41 min 93.2% 0 s _dispatch_workloop_worker_thread$VARIANT$mp 9.41 min 93.2% 0 s _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp 9.41 min 93.2% 0 s _dispatch_queue_invoke$VARIANT$mp 9.37 min 92.9% 0 s _dispatch_queue_serial_drain$VARIANT$mp 9.37 min 92.9% 0 s _dispatch_client_callout 9.37 min 92.9% 0 s _dispatch_call_block_and_release 8.78 min 87.0% 0 s -[FRepo deferredInit] 8.77 min 87.0% 0 s -[FRepo restoreWrites] 7.30 min 72.3% 0 s -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] 6.55 min 64.9% 1.00 ms __22-[FRepo restoreWrites]_block_invoke 5.69 min 56.3% 4.00 ms -[FSyncTree applyUserMergeAtPath:changedChildren:writeId:] 5.67 min 56.2% 8.00 ms -[FWriteTree addMergeAtPath:changedChildren:writeId:] 5.63 min 55.8% 5.00 ms -[FCompoundWrite addCompoundWrite:atPath:] 5.63 min 55.8% 0 s -[FImmutableTree forEach:] 5.63 min 55.8% 1.00 ms -[FImmutableTree forEachPathSoFar:withBlock:] 3.43 min 34.0% 1.00 ms -[FArraySortedDictionary enumerateKeysAndObjectsReverse:usingBlock:] 3.42 min 33.9% 3.00 ms __45-[FImmutableTree forEachPathSoFar:withBlock:]_block_invoke 3.32 min 32.9% 7.00 ms -[FImmutableTree forEachPathSoFar:withBlock:] 3.31 min 32.8% 6.00 ms __42-[FCompoundWrite addCompoundWrite:atPath:]_block_invoke 3.22 min 31.9% 9.00 ms -[FCompoundWrite addWrite:atPath:] 语法。它在Kotlin 1.0或更新版本中不存在。

答案 1 :(得分:2)

Annotation Use-site Targets记录了这一点。

  

如果您有多个具有相同目标的注释,则可以通过在目标后添加括号并将所有注释放在括号内来避免重复目标

当然,您也可以使用一个注释。但是你需要确保设置目标。这至少是@。因此它可以是@Inject@[Inject],也可以是多个注释@[Inject SomeScope]