How to append or prepend an element to a tuple in Scala

前端 未结 4 1696
灰色年华
灰色年华 2020-12-05 07:03

I have a tuple and want to add an element without loosing type safety. This is what I want to achieve:

val tuple = (\"\", 1, 1f) // (String, Int, Float)

val         


        
4条回答
  •  情书的邮戳
    2020-12-05 07:49

    Shapeless now does it. Adding

    import shapeless.syntax.std.tuple._
    

    before your code just compiles.

提交回复
热议问题