Ctrl+P again to print, arrows/tab to navigate results, enter to confirm

    Printing

    Here is the shortest way to print a string:

    _=@import("std").os.linux.write(1,"Hello!",6);
    

    And the shortest way to print anything that isn't a string:

    const s=@import("std");_=s.os.linux.dup2(1,2);s.debug.print("{}\n",.{i});
    

    Note that s.os.linux.dup2(1,2) returns 2, so you can usually combine it with an expression.

    Note that the string printer, os.linux.write, takes a number as its first argument. If the number is 2, it prints to stderr, which code.golf ignores, so this can be used for conditional printing. Passing any number other than 1 or 2 crashes the program.

    Arguments

    Looping over arguments:

    const s=@import("std");pub fn main(i:s.process.Init)void{for(i.minimal.args.vector[1..])|x|...;}
    

    Variable declarations

    When declaring more than one variable of the same type, it is often good to avoid declaring the type each time.

    var a:u8=0;var b:u8=0;
    

    vs.

    var a:u8=0;var b=a;
    

    Usize

    Don't declare a variable as usize, u64 is the same thing

    var x:usize=0;
    var x:u64=0;