ios - How to show all the elements of an array in swift? -
i have array this: var array = ["chinese","italian", "japanase", "french" , "american"]
and want print out seperate elements on new line.
how can this?
you can iterate through array , print out elements on new line:
for element in array { println(element) }
update
for swift 2 , swift 3:
for element in array { print(element) }
or if want on same line:
for element in array { print(element, terminator: " ") }
Comments
Post a Comment