Class StringLib.format

All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
Enclosing class:
StringLib

public static final class StringLib.format extends VarArgFunction implements com.esotericsoftware.kryo.KryoSerializable
string.format (formatstring, ...) Returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). The format string follows the same rules as the printf family of standard C functions. The only differences are that the options/modifiers *, l, L, n, p, and h are not supported and that there is an extra option, q. The q option formats a string in a form suitable to be safely read back by the Lua interpreter: the string is written between double quotes, and all double quotes, newlines, embedded zeros, and backslashes in the string are correctly escaped when written. For instance, the call string.format('%q', 'a string with "quotes" and \n new line') will produce the string: "a string with \"quotes\" and \ new line" The options c, d, E, e, f, g, G, i, o, u, X, and x all expect a number as argument, whereas q and s expect a string. This function does not accept string values containing embedded zeros, except as arguments to the q option.
  • Method Details

    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
      Specified by:
      write in interface com.esotericsoftware.kryo.KryoSerializable
      Overrides:
      write in class LibFunction
    • read

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.KryoSerializable
      Overrides:
      read in class LibFunction
    • invoke

      public Varargs invoke(Varargs args)
      Description copied from class: VarArgFunction
      Subclass responsibility. May not have expected behavior for tail calls. Should not be used if: - function has a possibility of returning a TailcallVarargs
      Overrides:
      invoke in class VarArgFunction
      Parameters:
      args - the arguments to the function call.