mirror of
https://github.com/nushell/nushell.git
synced 2025-01-10 16:28:50 +01:00
Add example showing first class closure to do
(#7473)
# Description Demonstrates that you can use `do` to execute stored closures and evaluate their captures properly. # Tests + Formatting As an example test increases coverage of the usage to execute first class closures. Additional tests using that found in `tests/shell/pipeline/commands/internal.rs`
This commit is contained in:
parent
80a69224f7
commit
735a7a21bd
@ -183,6 +183,11 @@ impl Command for Do {
|
|||||||
example: r#"do { echo hello }"#,
|
example: r#"do { echo hello }"#,
|
||||||
result: Some(Value::test_string("hello")),
|
result: Some(Value::test_string("hello")),
|
||||||
},
|
},
|
||||||
|
Example {
|
||||||
|
description: "Run a stored first-class closure",
|
||||||
|
example: r#"let text = "I am enclosed"; let hello = {|| echo $text}; do $hello"#,
|
||||||
|
result: Some(Value::test_string("I am enclosed")),
|
||||||
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Run the closure and ignore both shell and external program errors",
|
description: "Run the closure and ignore both shell and external program errors",
|
||||||
example: r#"do -i { thisisnotarealcommand }"#,
|
example: r#"do -i { thisisnotarealcommand }"#,
|
||||||
|
Loading…
Reference in New Issue
Block a user