[英]choosing a shapeless HList instead of a case class
What are the advantages of using a shapeless HList over a case class in Scala? 在Scala中使用无形HList而不是案例类有什么好处? In what situations would you not want to use a HList? 在什么情况下,你会不会想使用HList?
You may want to read these questions first: 您可能希望首先阅读这些问题:
Are HLists nothing more than a convoluted way of writing tuples? HLists只不过是一种复杂的编写元组的方式吗?
How can I use the new Slick 2.0 HList to overcome 22 column limit? 如何使用新的Slick 2.0 HList克服22列限制?
Essentially case classes
are tuples
underneath, which in turn map to a Java classes
. 基本上case classes
是下面的tuples
,它们又映射到Java classes
。 However HList
is a List like
data structure. 然而, HList
是List like
数据结构的List like
。 So you may have to traverse the list to access a particular member HList
. 因此,您可能必须遍历列表才能访问特定成员HList
。 This is more costly than using a case class member or a tuple member. 这比使用案例类成员或元组成员更昂贵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.