swift - Add String to variable -


i have variable let name = ["pete"] , want add second name it.

name array, add element can use append. you'll need make name variable though:

// note - `name` declared `var` instead of `let` var name = ["pete"] name.append("anothername")  println(name) // ["pete", "anothername"] 

(if you're unfamiliar arrays recommend take @ the swift programming language: collection types.)

the naming of variable suggests didn't intend array though. in case wanted string, do:

var name = "pete" name += " secondname" println(name) // pete secondname 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -