Added $ for openarrays. Fixes #7940.

This commit is contained in:
data-man
2018-06-01 21:28:23 +03:00
parent cb87bba82f
commit b4626a220b
2 changed files with 9 additions and 0 deletions

View File

@@ -3443,6 +3443,14 @@ when not defined(nimNoArrayToString):
## generic ``$`` operator for arrays that is lifted from the components
collectionToString(x, "[", ", ", "]")
proc `$`*[T](x: openarray[T]): string =
## generic ``$`` operator for openarrays that is lifted from the components
## of `x`. Example:
##
## .. code-block:: nim
## $(@[23, 45].toOpenArray(0, 1)) == "[23, 45]"
collectionToString(x, "[", ", ", "]")
proc quit*(errormsg: string, errorcode = QuitFailure) {.noReturn.} =
## a shorthand for ``echo(errormsg); quit(errorcode)``.
echo(errormsg)