mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-21 21:42:23 -05:00
primitive_types3 solution
This commit is contained in:
parent
e1051724c3
commit
0338b1cbdf
3 changed files with 15 additions and 6 deletions
|
@ -1,12 +1,11 @@
|
|||
// Create an array with at least 100 elements in it where the ??? is.
|
||||
|
||||
fn main() {
|
||||
let a = ???
|
||||
// TODO: Create an array with at least 100 elements in it where the ??? is.
|
||||
// let a = ???
|
||||
|
||||
if a.len() >= 100 {
|
||||
println!("Wow, that's a big array!");
|
||||
} else {
|
||||
println!("Meh, I eat arrays like that for breakfast.");
|
||||
panic!("Array not big enough, more elements needed")
|
||||
panic!("Array not big enough, more elements needed");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ name = "primitive_types3"
|
|||
dir = "04_primitive_types"
|
||||
test = false
|
||||
hint = """
|
||||
There's a shorthand to initialize Arrays with a certain size that does not
|
||||
There's a shorthand to initialize arrays with a certain size that doesn't
|
||||
require you to type in 100 items (but you certainly can if you want!).
|
||||
|
||||
For example, you can do:
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
fn main() {
|
||||
// An array with 100 elements of the value 42.
|
||||
let a = [42; 100];
|
||||
|
||||
if a.len() >= 100 {
|
||||
println!("Wow, that's a big array!");
|
||||
} else {
|
||||
println!("Meh, I eat arrays like that for breakfast.");
|
||||
panic!("Array not big enough, more elements needed");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue