gpt4 book ai didi

string - 如何在没有迭代的情况下在 Dart 中将 list 转换为 String?

转载 作者:行者123 更新时间:2023-12-03 02:38:44 25 4
gpt4 key购买 nike

Dart 中是否有类似 String.join() 的方法? Java和C#中的方法?
输入:

nums: ["20",  "3005",  "2"]
输出:
nums = "2030052"

最佳答案

join是 List 类的方法,而不是 String:

List<String> yourList = ["20", "3005", "2"];

// To test that the above the above
yourList.join() == '2030052'; // true
yourList.join(',') == '20,3005,2'; // true, with "," delimiter

关于string - 如何在没有迭代的情况下在 Dart 中将 list<String> 转换为 String?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48014624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com