Confirm
Confirm[expr]
confirms that expr does not represent an error, otherwise throwing a Failure to the nearest lexically surrounding Enclose.
Confirm[expr,info]
if expr represents an error, evaluates info and includes the result in the thrown Failure.
Confirm[expr,info,tag]
uses the specified tag for any thrown errors.
更多信息
- expr is considered an error if it is $Canceled or satisfies MissingQ or FailureQ.
- expr is returned unchanged if it does not represent an error.
- The default value of info is Null.
- Generally, if expr represents an error then it is wrapped in a Failure before it is thrown. However, if expr has head Failure with tag "ConfirmationFailed", and no info has been provided, Confirm will throw expr without wrapping it in another Failure.
范例
打开所有单元关闭所有单元基本范例 (2)
Scope (3)
Confirm stops evaluation and returns to the matching Enclose when it throws an error:
Create a function that calls Confirm with a tag so that it can be caught by an enclosing function:
Errors are wrapped in Failure before they are thrown, unless they came from another call to a confirmation function:
文本
Wolfram Research (2020),Confirm,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Confirm.html.
CMS
Wolfram 语言. 2020. "Confirm." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/Confirm.html.
APA
Wolfram 语言. (2020). Confirm. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Confirm.html 年