当前位置:网站首页>d的is表达式
d的is表达式
2022-06-26 12:58:00 【fqbqrr】
考虑普通局部变量:
int foo = 0;
可分析为:
Type_Name Local_Name Operator Initial_Value
考虑is
表达式:
is(typeof(func) Params == __parameters)
这样:
is(Type_Name Local_Name Deconstruction_Pattern)
//后2都是可选的.
类型 | 意思 |
---|---|
is(Type) | 有类型,但省略了本地名称和解构模式.它只关心类型是否存在. |
is(Type:something) | 用: 表明可转为该类型 的析构模式 . |
is(Type==something) | 精确匹配,最易记 |
is(Type Identifier) | 必须存在某种类型,像整 a 一样,名字在型 后.跳过析构 类型 |
is(Type Identifier:something) | 与前: 一样,但可可选本地名 |
is(Type Identifier==something) | 同样 |
文档中还有其他,class
等,大多很简单,可初化标识符
为其他
.看起来,is(A B == C)
像B与C
在比较,但这是在声明变量
.== C
整个为析构模式
,B
为变量.类型整 a=10
.
is(MyClass Parents == super)
==super
,其为基类
.因此把==
当作匹配析构模式
.更有意义.
static if(is(int[10] == T[N], T, size_t N))
只是,扩展了析构模式
.==
精确比较,T[N]
为声明模型.问题是多数时候
编译器不会告诉你模式格式不正确
,只是不匹配.因而通过静态断言
等来测试.
这样用,可选复杂名:
static if(is(int[10] OriginalType == T[N], T, size_t N))
知道如何分解的时候,就容易搞懂了.
边栏推荐
- Mediapipe gestures (hands)
- 33、使用RGBD相机进行目标检测和深度信息输出
- 【MySQL从入门到精通】【高级篇】(二)MySQL目录结构与表在文件系统中的表示
- 7-1 n queen problem
- 李航老师新作《机器学习方法》上市了!附购买链接
- 去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程
- Wechat applet -picker component is repackaged and the disabled attribute is added -- below
- 免费的机器学习数据集网站(6300+数据集)
- Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value
- Jenkins build prompt error: eacces: permission denied
猜你喜欢
Common faults of MySQL database - forgetting database password
VTK 圆柱体的生成与渲染
There are many contents in the widget, so it is a good scheme to support scrolling
ES6 module
LAMP编译安装
Reprint - easy to use wechat applet UI component library
Select tag - uses the default text as a placeholder prompt but is not considered a valid value
Use of wangeditor rich text editor
33. Use rgbd camera for target detection and depth information output
古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
随机推荐
7-3 minimum toll
Learn how to develop owl components by hand (7): practical use of owl projects
SQL assigns the field value of data table B to a column in data table a
Aesthetic experience (episode 238) Luo Guozheng
[how to connect the network] Chapter 2 (next): receiving a network packet
微信小程序注册指引
MySQL explanation (I)
7-2 a Fu the thief
泰山OFFICE技术讲座:使用字体粗体的四种情形
Log in to the server using SSH key pair
Electron official docs series: Processes in Electron
Variable declaration of typescript
Firewall introduction
MySQL数据库常见故障——遗忘数据库密码
Basic configuration and test of Beifu twincat3 NCI in NC axis interface
古瑞瓦特沖刺港交所上市:創下“多個第一”,獲IDG資本9億元投資
Electron official docs series: References
Here Document免交互及Expect自动化交互
去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程
Go language - pipeline channel