我有一个清单
最终列表列表= [1、2、3、4、5、6、7];
如何将“输出”映射为新的列表,例如:
"1 and 2",
"3 and 4",
"5 and 6",
"7"
您可以使用以下功能来实现:
_getComponents(list) => list.isEmpty ? list :
([list
.take(2)
.join(' and ')
]..addAll(_getComponents(list.skip(2))));
调用该函数,例如:
List outPut = _getComponents(yourList);
说明:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句