Templates 这个语法是什么:模板tplname{op(id,[id2])}(params)

Templates 这个语法是什么:模板tplname{op(id,[id2])}(params),templates,syntax,operator-overloading,curly-braces,nim-lang,Templates,Syntax,Operator Overloading,Curly Braces,Nim Lang,在json模块中: template simpleGetOrDefault*{`{}`(node, [key])}(node: JsonNode, key: string): JsonNode = node.getOrDefault(key) 花括号是怎么回事(里面是什么)?这是一个例子 稍早在json模块中,您将找到带有以下签名的{}运算符的定义: proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode = ## Trave

在json模块中:

template simpleGetOrDefault*{`{}`(node, [key])}(node: JsonNode, key: string): JsonNode = node.getOrDefault(key)
花括号是怎么回事(里面是什么)?

这是一个例子

稍早在json模块中,您将找到带有以下签名的
{}
运算符的定义:

proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode =
  ## Traverses the node and gets the given value. If any of the
  ## keys do not exist, returns ``nil``. Also returns ``nil`` if one of the
  ## intermediate data structures is not an object.
“重写宏”一词的目标是截取只有一个字符串作为运算符参数的情况,并将其转换为对
getOrDefault
的简单调用