[MacRuby-devel] Method calls with variable unnamed arguments after the pseudo-hash part of the selector

Caio Chassot lists at caiochassot.com
Sun Oct 10 11:46:03 PDT 2010


I'm playing again with implementing the Hillegass book in MacRuby, and ran across this method:

    + (NSAlert *)alertWithMessageText:(NSString *)messageTitle
                        defaultButton:(NSString *)defaultButtonTitle
                      alternateButton:(NSString *)alternateButtonTitle
                          otherButton:(NSString *)otherButtonTitle              
            informativeTextWithFormat:(NSString *)informativeText, ...

    (http://bit.ly/d1JIeQ)

Now, the interesting part here is the ", ..." at the end. It takes variable arguments at the end that work as formatting arguments for informativeText, eg. sprintf(informativeText, ...).

In MacRuby, this is invalid syntax:

    NSAlert.alertWithMessageText("Delete?",
                   defaultButton:"Delete",
                 alternateButton:"Cancel",
                     otherButton:nil,
       informativeTextWithFormat:"delete %d people?",
                                  employees.count)


Surely, in this case it can be worked around with:

    NSAlert.alertWithMessageText("Delete?",
                   defaultButton:"Delete",
                 alternateButton:"Cancel",
                     otherButton:nil,
       informativeTextWithFormat:"delete #{employees.count} people?")

And I can also call it as:

    NSAlert.send(
      :"alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:",
      "Delete?", "Delete", "Cancel", nil, "delete %@ people?", employees.count)

but I was wondering if this is a known limitation in MacRuby's method call syntax.

So, is it known? Is there a plan to do anything about it?



More information about the MacRuby-devel mailing list