我有一根绳子:

countries = "India,Bangladesh,Srilanka,South Africa,Australia,Canada"

我需要从中获取一个数组:
countries = ["India","Bangladesh","Srilanka","South Africa","Australia","Canada"]

我该怎么做?

最佳答案

通过使用split方法:

countries = countries.split(",")

关于ruby - 如何将字符串转换为and数组?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22477445/

10-11 04:13