typescript - 为什么以下方法不给出语法错误?
问题描述
// There are three possible booleans available this.oneBoolean, this.otherBoolean and this.thirdBoolean not used in the scope of this method
canEditSomething(): boolean {
if(this.oneBoolean) {
return true
}
if (this.otherBoolean) {
return false
}
}
所以问题是如果上面的 if 条件都不满足,编译器或更准确地说是编译器在返回之前是否在方法范围的末尾添加了默认返回语句?
解决方案
推荐阅读
- assembly - 如何从 .asm 文件调用外部文件
- swift - 在 Swift 中从 NSData 读取一个 Int
- python - 列表(地图)错误:TypeError:只能将整数标量数组转换为标量索引
- spring - 为什么 Hybris 控制器端点不能使用 Postman 等工具作为 REST 使用?
- hyperledger - Hyperledger 作曲家休息服务器的隐私
- powershell - 导入 PowerShell 模块时,我可以挂钩哪些事件(.net、WMI 等)以执行操作?
- c# - 将参数传递给 ASP.NET Core 中的 jQuery 加载函数
- android - 为 Android 应用生成 SHA-256 密钥
- r - 转换为 plotly 的 ggplot2 图形在 Shiny 应用程序中没有响应
- python - 需要在 Python 中将 CSV 输出打印到单独的行中,而不是一个长字符串