Swift NSString function syntax usage

I have a basic question about swift function calling syntax. I have read documentation but not able to figure it out. So decided to put a query over here.

A piece of code i wrote

  • String to Double in XCode 6's Swift
  • How to add one project to another(Xcode)
  • When do I need to have both iVar and a property?
  • How to Merge PDF file with Annotation
  • iOS 6 (iPhone/iPad) Image Upload “Request Body Stream Exhausted” with NTLM/Windows Authentication
  • How to set x-axis on bar chart data - ios-charts?
  •     var string1 = NSString().stringByAppendingString("First string")
        var string2 = NSString.stringByAppendingString("Second string")
    
        println(string1)
        println(string2)
    

    Both string have same function calling but return type is different. And only difference here is (). I got out put like

    First string

    (Function)

    Question is why its not giving a warning/error. Is it that var string2 holds method body of stringByAppendingString? Whats going on, New swift developer like me can easily make a this type of typo mistake and not able to figure out.

    Can you please explain why its not return value?

    Solutions Collect From Internet About “Swift NSString function syntax usage”

    This happens because swift methods are curried functions (you can find detailed explanation in Ole Begemann’s post).

    So what you actually got in the following line:

    var string2 = NSString.stringByAppendingString("Second string")
    

    is a function that takes a string as parameter and returns the result of

    "Second string".stringByAppendingString(parameter)
    

    You can check that by calling string2 as an ordinary function:

    string2("123")
    // Prints: "Second string123"