Swift implicit parameters

Swift comes with some implicitly defined variables – that are variables that are accessible in your code even though you’ve not explicitly defined them. These variables are helpful when logging errors or writing test code.

  • __COLUMN__ (Int): The column number in the source file on which the currently executing code appears
  • __FILE__ (String): The filename of the file in which the currently executing code appears
  • __FUNCTION__ (String): The name of the declaration in which the currently executing code appears
  • __LINE__ (Int): The line number in the source file on which the currently executing code appears
  • C_ARGC (CInt): The number of command line arguments passed to the executable
  • C_ARGV (UnsafePointer<CString>) (appears not to be available in playgrounds?): The command line arguments passed to the executable, C_ARGV[0] is the first argument, C_ARGV[1] is the second argument, etc.

tomkausch

Leave a Reply

Your email address will not be published. Required fields are marked *