File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1888,8 +1888,15 @@ fn main() {
1888
1888
1889
1889
The first thing we changed was to ` use std::rand ` , as the docs
1890
1890
explained. We then added in a ` let ` expression to create a variable binding
1891
- named ` secret_number ` , and we printed out its result. Let's try to compile
1892
- this using ` cargo build ` :
1891
+ named ` secret_number ` , and we printed out its result.
1892
+
1893
+ Also, you may wonder why we are using ` % ` on the result of ` rand::random() ` .
1894
+ This operator is called 'modulo', and it returns the remainder of a division.
1895
+ By taking the modulo of the result of ` rand::random() ` , we're limiting the
1896
+ values to be between 0 and 99. Then, we add one to the result, making it from 1
1897
+ to 100.
1898
+
1899
+ Let's try to compile this using ` cargo build ` :
1893
1900
1894
1901
``` {notrust,no_run}
1895
1902
$ cargo build
You can’t perform that action at this time.
0 commit comments