Enclose
更多信息
- Enclose[expr,…] returns the value of expr if no error was caught during its evaluation. »
- Enclose will not catch errors that have already been caught by an inner Enclose.
- When no tag is provided, Enclose will add tags to all untagged lexically contained confirmation functions. »
- tag can be any expression including a pattern.
- Catches errors thrown by Confirm, ConfirmBy, ConfirmMatch, ConfirmQuiet, and ConfirmAssert.
- Enclose effectively calls Catch with a special tag.
- The default value of f is Identity.
- If f is a string, err[f] will be returned instead of f[err]. »
范例
打开所有单元 关闭所有单元基本范例 (2)
Scope (6)
Process an error before returning:
Set f to "Expression" to propagate errors without wrapping in Failure:
The innermost Enclose has precedence:
Use a tag to pass an error to the outer Enclose:
Provide a constant function for f to return a fixed value in the event of any error:
Applications (3)
文本
Wolfram Research (2020),Enclose,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Enclose.html.
CMS
Wolfram 语言. 2020. "Enclose." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/Enclose.html.
APA
Wolfram 语言. (2020). Enclose. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Enclose.html 年
BibTeX
@misc{reference.wolfram_2025_enclose, author="Wolfram Research", title="{Enclose}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Enclose.html}", note=[Accessed: 18-April-2026]}
BibLaTeX
@online{reference.wolfram_2025_enclose, organization={Wolfram Research}, title={Enclose}, year={2020}, url={https://reference.wolfram.com/language/ref/Enclose.html}, note=[Accessed: 18-April-2026]}