[MacRuby-devel] Method calls with variable unnamed arguments after the pseudo-hash part of the selector
Laurent Sansonetti
lsansonetti at apple.com
Sun Oct 10 13:23:16 PDT 2010
Hi Caio,
You seem to have found a bug in the parser :) Could you file that as a ticket?
Thanks,
Laurent
On Oct 10, 2010, at 11:46 AM, Caio Chassot wrote:
> 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?
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101010/0fbcf477/attachment.html>
More information about the MacRuby-devel
mailing list