[Swift-user] Formatting in Swift

Justin M Wozniak wozniak at mcs.anl.gov
Thu Jun 24 13:22:34 CDT 2010


If you are using trunk, you can try the new tracef() function:

        Formatted trace output.
        Example: tracef("\t%s\n", "hello");
        Differences from trace():
        1) respects \t, \n and \\;
        2) allows for typechecked format specifiers;
        3) allows for consumption of variables without display (%k);
        4) does not impose any formatting (commas, etc.).
        Format specifiers:
            %%: % sign.
            %p: Not typechecked, output as in trace().
            %i: Typechecked int output.
            %s: Typechecked string output.
            %k: Variable sKipped, no output.

On Thu, 24 Jun 2010, Lee S wrote:

> Hello,
>
> I'm trying to figure out how I can control formatting in Swift,
> For example, in c-scripting there is set myVar = `printf "%04d" {$Integer}`
> Is there a way to access these formatting options in swift?
>
> Thank you
>
>
>

-- 
Justin M Wozniak



More information about the Swift-user mailing list