如何扁平化嵌套元组? [英] How to flatten a nested tuple?

查看:144
本文介绍了如何扁平化嵌套元组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌套的元组结构,如(String,(String,Double)),我想将其转换为(String,String,Double).我有各种各样的嵌套元组,并且我不想手动转换每个元组.有什么方便的方法吗?

I have a nested tuple structure like (String,(String,Double)) and I want to transform it to (String,String,Double). I have various kinds of nested tuple, and I don't want to transform each manually. Is there any convenient way to do that?

推荐答案

如果使用不变形,<一个href ="https://github.com/milessabin/shapeless/blob/master/examples/src/main/scala/shapeless/examples/flatten.scala" rel ="noreferrer">这正是我认为您需要.

If you use shapeless, this is exactly what you need, I think.

这篇关于如何扁平化嵌套元组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆