typescript - 这个 TypeScript 代码中的“:”是什么意思?
问题描述
我不明白:
这段代码中 second 的含义是什么:
getDish(id: number): Observable<Dish> {
return this.restangular.one('dishes',id).get();
}
我知道第一种:
方式 id 具有类型号,它是getDish()
函数的输入参数。但是第二个:
做什么呢?它是函数的输出类型,getDish()
并且意味着输出是Dish
具有该Observable
类型的类的对象吗?
解决方案
请查看以下说明
id: number <-- type of the id variable is number
getDish(id: number): Observable<Dish> <-- the return value of the function i GetDish is of type Observable<Dish>
推荐阅读
- r - 如何通过附加不同长度的字符串来消除重复字符串的歧义?
- java - 使用 appache common-codec library 获取无效数据解码
- javascript - 如何在不使用 z-index 的情况下使用 css 网格反向堆叠元素?
- react-native - 我在 react native (android) 项目中没有收到来自 AWS Pinpoint 的推送通知
- python - 在 python 测试模块中定义帮助类可以吗?
- php - PHP - 将文件从一个目录迁移到另一个 - 图像权限被拒绝
- linux - 从管道转发数据
- c# - 在 MacOS 上后台运行 .NetCore 控制台应用程序
- python - Connecting to SQL Server throws pyodbc.InterfaceError
- java - 多个队列的最短作业优先