@@ -294,11 +294,11 @@ are not semicolons in the blocks of the second snippet. This is
294
294
important; the lack of a semicolon after the last statement in a
295
295
braced block gives the whole block the value of that last expression.
296
296
297
- Put another way, the semicolon in Rust * ignores the value of an
298
- expression * . Thus, if the branches of the ` if ` had looked like ` { 4; } ` ,
299
- the above example would simply assign ` () ` (unit or void) to
300
- ` price ` . But without the semicolon, each branch has a different value,
301
- and ` price ` gets the value of the branch that was taken.
297
+ Put another way, the semicolon in Rust * ignores the value of an expression * .
298
+ Thus, if the branches of the ` if ` had looked like ` { 4; } ` , the above example
299
+ would simply assign ` () ` (nil or void) to ` price ` . But without the semicolon, each
300
+ branch has a different value, and ` price ` gets the value of the branch that
301
+ was taken.
302
302
303
303
In short, everything that's not a declaration (` let ` for variables,
304
304
` fn ` for functions, et cetera) is an expression, including function bodies.
@@ -839,7 +839,7 @@ fn point_from_direction(dir: Direction) -> Point {
839
839
Tuples in Rust behave exactly like structs, except that their fields
840
840
do not have names (and can thus not be accessed with dot notation).
841
841
Tuples can have any arity except for 0 or 1 (though you may consider
842
- unit , ` () ` , as the empty tuple if you like).
842
+ nil , ` () ` , as the empty tuple if you like).
843
843
844
844
~~~~
845
845
let mytup: (int, int, float) = (10, 20, 30.0);
@@ -891,7 +891,7 @@ fn int_to_str(i: int) -> ~str {
891
891
}
892
892
~~~~
893
893
894
- Functions that do not return a value are said to return unit , ` () ` ,
894
+ Functions that do not return a value are said to return nil , ` () ` ,
895
895
and both the return type and the return value may be omitted from
896
896
the definition. The following two functions are equivalent.
897
897
0 commit comments