简体   繁体   English

Scala反射-为什么选择TypeTag和Type?

[英]Scala reflection - why TypeTag and Type?

These two types/classes in the Scala reflection API seem to represent the same thing. Scala反射API中的这两种类型/类似乎表示同一件事。 Why are they two separate types? 为什么它们是两种不同的类型?

scala.reflect.api.Universe.Type
scala.reflect.api.Universe.TypeTag

Link to scala docs: scala.reflect.api.Universe 链接到scala文档: scala.reflect.api.Universe

Type is a reflection artifact bound to a particular universe. Type是绑定到特定Universe的反射工件。 TypeTag is a type factory, capable of instantiating a type in any universe. TypeTag是类型工厂,能够在任何Universe中实例化类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM