在烧杯文档中,他们讨论了不在createfunc调用中直接传递参数,而是使用闭包。你知道吗
The creation function must not accept any arguments as it won’t be called with any. Options affecting the created value can be passed in by using closure scope on the creation function:
我可以在闭包中找到的所有示例和文档都指向一个嵌套函数调用,其中第一个引用了一个变量。在这种情况下,我不明白如何编写闭包,因为它不是一个函数,而是一个键值变量。你知道吗
results = tmpl_cache.get(key=search_param, createfunc=get_results)
如何将variable_a
传递到createfunc
中的get_results(variable_a)
?你知道吗
像这样,还是类似的?你知道吗
get_results_func
返回一个函数指针,由于它位于闭包中,因此将正确调用get_results
。你知道吗相关问题 更多 >
编程相关推荐