What are the advantages of using a shapeless HList over a case class in Scala? In what situations would you not want to use a HList?
You may want to read these questions first:
Are HLists nothing more than a convoluted way of writing tuples?
How can I use the new Slick 2.0 HList to overcome 22 column limit?
Essentially case classes
are tuples
underneath, which in turn map to a Java classes
. However HList
is a List like
data structure. So you may have to traverse the list to access a particular member HList
. This is more costly than using a case class member or a tuple member.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.