在看 *The Rust Programming Language* 的时候 Functions 这一节讲到 expression 和 statement 的区别。想弄明白 *println!* 是 expression 还是 statement . 找到这两篇答案:
- 是 [statement]( https://users.rust-lang.org/t/expression-statements/7733)
>since it has a semicolon, it's a statement. And if you have a block like { statement; statement; expression } then that final expression becomes the value for the whole block.
- 是 [expression]( http://stackoverflow.com/a/28439789/4974466)
>'println!()' is a macro expanding to an expression. It has no useful return value, but it is an expression (mostly because almost everything is an expression, including function calls and blocks).
能有前辈解释一下正确的理解是什么嘛?
- 是 [statement]( https://users.rust-lang.org/t/expression-statements/7733)
>since it has a semicolon, it's a statement. And if you have a block like { statement; statement; expression } then that final expression becomes the value for the whole block.
- 是 [expression]( http://stackoverflow.com/a/28439789/4974466)
>'println!()' is a macro expanding to an expression. It has no useful return value, but it is an expression (mostly because almost everything is an expression, including function calls and blocks).
能有前辈解释一下正确的理解是什么嘛?