repr
repr(x)
Create a string from any value using the showall
function.
Examples
julia> repr(3.14)
"3.14"
julia> repr("Hello, Julia!")
"\"Hello, Julia!\""
julia> repr([1, 2, 3])
"[1, 2, 3]"
julia> repr((x = 1, y = 2))
"(x = 1, y = 2)"
The repr
function in Julia is used to generate a string representation of a value using the showall
function. It is commonly used to obtain a detailed and unambiguous representation of an object. Here are some examples of using repr
for different types of values:
-
Float: When
repr
is called with a floating-point number, it returns the string representation of that number. -
String: For a string value,
repr
returns the string representation enclosed in double quotes. -
Array: When an array is passed to
repr
, it generates a string representation of the array, including the elements. - Tuple: For tuples,
repr
returns a string representation of the tuple with each element shown.
Note that repr
is commonly used for debugging and displaying values in a clear and readable format. It can be particularly helpful when dealing with complex data structures.
See Also
ascii, base64decode, Base64DecodePipe, base64encode, Base64EncodePipe, bin, bits, bytestring, charwidth, chomp, chop, chr2ind, contains, endswith, escape_string, graphemes, ind2chr, iscntrl, istext, isupper, isvalid, join, lcfirst, lowercase, lpad, lstrip, normalize_string, num2hex, parseip, randstring, readuntil, replace, repr, rpad, rsplit, rstrip, search, searchindex, split, startswith, string, stringmime, strip, strwidth, summary, takebuf_string, ucfirst, unescape_string, uppercase, utf16, utf32, utf8, wstring,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.