print_joined
print_joined(io, items, delim, [last])
Print elements of items to io with delim between them. If last is specified, it is used as the final delimiter instead of delim.
Examples
julia> print_joined(stdout, [1, 2, 3, 4], ", ")
1, 2, 3, 4
julia> print_joined(stdout, ["apple", "banana", "orange"], " | ", "and")
apple | banana | orange and
- The
print_joinedfunction takes an output streamio, a collection ofitemsto print, a delimiterdelimto separate the items, and an optionallastdelimiter to use at the end. - In the first example, the elements
[1, 2, 3, 4]are printed to the standard output (stdout) with", "as the delimiter. - In the second example, the strings
["apple", "banana", "orange"]are printed to the standard output with" | "as the delimiter and"and"as the last delimiter.
Common mistake example:
julia> print_joined(stdout, [1, 2, 3, 4], ", ", "and")
1, 2, 3, 4and
In this example, the user mistakenly provided "and" as the last delimiter instead of "and ". As a result, there is no space between the last item and the "and" delimiter. It's important to ensure the correct format of the delimiters to achieve the desired output.
See Also
:@printf, :@sprintf, display, displayable, dump, info, isprint, print, println, print_escaped, print_joined, print_shortest, print_unescaped, print_with_color, pushdisplay, redisplay, show, showall, showcompact, sprint, versioninfo,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.