使用字符串参数的方法在Swift中打印

时间:2014-07-02 04:54:51

标签: swift

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

以上代码打印消息:"这是消息=> ,对于nameJohn"

,问候消息是Hello
  println("This was the message => ",greetingMessage("John", message: "Hello"))

这里的问题是","字符。如何修改它以使其不会出现在输出中?

感谢。

2 个答案:

答案 0 :(得分:2)

尝试

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

答案 1 :(得分:1)

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

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