swift 注解 (和java比照)@attribute name
JAVA 注解 swift name attribute
2023-09-11 14:18:45 时间
Attributes provide more information about a declaration or type. There are two kinds of attributes in Swift, those that apply to declarations and those that apply to types.
You specify an attribute by writing the @
symbol followed by the attribute’s name and any arguments that the attribute accepts:
- @attribute name
- @attribute name(attribute arguments)
Some declaration attributes accept arguments that specify more information about the attribute and how it applies to a particular declaration. These attribute arguments are enclosed in parentheses, and their format is defined by the attribute they belong to.
- @dynamicMemberLookup
- struct DynamicStruct {
- let dictionary = ["someDynamicMember": 325,
- "someOtherMember": 787]
- subscript(dynamicMember member: String) -> Int {
- return dictionary[member] ?? 1054
- }
- }
- let s = DynamicStruct()
- // Using dynamic member lookup
- let dynamic = s.someDynamicMember
- print(dynamic)
- // Prints "325"
- // Calling the underlying subscript directly
- let equivalent = s[dynamicMember: "someDynamicMember"]
- print(dynamic == equivalent)
https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#grammar_attribute-argument-clause
相关文章
- MySQL_(Java)提取工具类JDBCUtils
- Java 开发环境配置--eclipse工具进行java开发
- Java魔法堂:注解用法详解——@SuppressWarnings
- Java实现 LeetCode 488 祖玛游戏
- Java实现蓝桥杯互补二元组
- java实现砝码称重
- Java实现8枚硬币问题(减治法)
- Java实现 蓝桥杯VIP 算法提高 林丹大战李宗伟
- Java实现 蓝桥杯VIP 算法训练 黑色星期五
- Java 蓝桥杯 算法训练 字符串的展开 (JAVA语言实现)
- Java通过mysql-connector-java-8.0.11连接MySQL Server 8.0遇到的几个问题
- Java字节码(.class文件)的代码解析
- 【JAVA】java中的length和length()
- 【JAVA】 02-Java对象细节
- Java AOP研究之@Aspect注解的工作原理
- 【译】11条Java异常处理的最佳实践
- 【java】Java经典面试题整理(附答案)
- 【java】EJB(Enterprise Java Bean)概述
- Java中静态方法的使用
- Java中成员变量和局部变量的区别
- 力扣——834. 树中距离之和(Java实现+分析)
- 【Java用法】java 8两个List集合取交集、并集、差集、去重并集
- 【华为OD机试 2023】单词倒序(C++ Java JavaScript Python)
- 对Java 注解的一些理解
- Java 自定义注解结合 Aop 切面和本地缓存实现接口防重复请求提交
- 【java】Java IO体系总览
- 【跨域】Java后端解决跨域问题