Mojo function
print[*Ts: Writable](*values: *Ts, *, sep: StringSlice[StaticConstantOrigin] = " ", end: StringSlice[StaticConstantOrigin] = "\n", flush: Bool = False, var file: FileDescriptor = stdout)
Prints elements to the text stream. Each element is separated by sep and followed by end.
This function accepts any number of values, but their types must implement
the Writable trait. Most built-in types
(like Int, Float64, Bool, String) implement both
Stringable and
Writable traits. If a type only
implements Stringable, it can still be printed by first converting it to
String.
For string formatting, use the
format() function.
Examples:
print("Hello, World!") # Hello, World!
print("The answer is", 42) # The answer is 42
print("{} is {}".format("Mojo", "π₯")) # Mojo is π₯Parameters:
- β*Ts (
Writable): The elements types.
Args:
- β*values (
*Ts): The elements to print. - βsep (
StringSlice): The separator used between elements. - βend (
StringSlice): The String to write after printing the elements. - βflush (
Bool): If set to true, then the stream is forcibly flushed. - βfile (
FileDescriptor): The output stream.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!