Documentation only, add 1 example (#18633)

This commit is contained in:
Juan Carlos 2021-08-03 13:16:33 -03:00 • committed by GitHub
commit 6563a685c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1157,6 +1157,24 @@ the ordinary AST predicates:
a = b a = b
inc a, c inc a, c
Another example:
.. code-block:: nim
proc somefunc(s: string) = assert s == "variable"
proc somefunc(s: string{nkStrLit}) = assert s == "literal"
proc somefunc(s: string{nkRStrLit}) = assert s == r"raw"
proc somefunc(s: string{nkTripleStrLit}) = assert s == """triple"""
proc somefunc(s: static[string]) = assert s == "constant"
# Use parameter constraints to provide overloads based on both the input parameter type and form.
var variable = "variable"
somefunc(variable)
const constant = "constant"
somefunc(constant)
somefunc("literal")
somefunc(r"raw")
somefunc("""triple""")
Pattern operators Pattern operators
----------------- -----------------