组合数组中的元素

时间:2014-09-16 18:41:10

标签: ios swift

感谢您阅读此问题。

  

让foodArray = [" pasta"," cheese"," banana"," water"]

     

让expectOutput ="意大利面;奶酪;香蕉;水"

将foodArray转换为expectedOutput会有什么好方法?

谢谢。

1 个答案:

答案 0 :(得分:1)

let foodArray = ["pasta", "cheese", "banana", "water"]

let expectedOutput = "pasta;cheese;banana;water"
let actualOutput = join(";", foodArray)

let worked = expectedOutput == actualOutput

workedtrue