2
func greetingMessage(name:String,message:String)->String{
    return "Greeting message  is \(message) for name\(name)"
}

The above code prints the message : "This was the message => , Greeting message is Hello for nameJohn"

  println("This was the message => ",greetingMessage("John", message: "Hello"))

The problem here is the "," character. How do I modify this so that it doesn't appear in the output ?

Thanks.

1
  • I am trying to remove "," else everything is okie. Commented Jul 2, 2014 at 4:58

2 Answers 2

2

Try

  println("This was the message => " + greetingMessage("John", message: "Hello"))
Sign up to request clarification or add additional context in comments.

4 Comments

So, this is now same as Java
Yes, to combine 2 different strings in Swift, we are using +.
I also noticeed If I use "," then it prints the string in () parenthesis in console.
I am actually surprised that we can use "," to print something out on swift. I don't know how it has parenthesis as well.
1
func greetingMessage(name: String, message: String) -> String {
    return "Greeting message is \(message) for name \(name)"
}

println("This was the message => " + greetingMessage("John", "Hello"))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.