scala - Scala协方差推断类型List [Any]?
问题描述
我遇到了以下 Scala 片段,它表示List
带有“cons”运算符的 a(类似于::
):
sealed trait List[+A] {
def ::[A](that: A) = Cons(that, this)
}
final case object Nil extends List[Nothing]
final case class Cons[+A](head: A, tail: List[A]) extends List[A]
为什么List[Any]
推断的返回类型是::
?
解决方案
推荐阅读
- php - 通过自动化脚本找到 PHP.ini
- autocomplete - gdb 打印出奇怪的完成
- spring-mvc - 谁能告诉我为什么在将表单提交到数据库spring mvc时出现此错误
- yosys - 选择节点的MFFC
- c# - 使用 EF 6.0 和代码优先的一对一 EntityTypeConfiguration
- tinymce - 将自定义简码占位符添加到 TinyMCE 5
- powershell - Powershell - 复制权限成员 - 基于OU的过滤器
- sql-server - COUNT(*) 如何知道在这些示例中计数的是什么?
- javascript - 如何从数组中过滤出只是现有元素变体的所有元素?
- java - 如何在 HiveMetastoreListener 中检索查询字符串?