From 9c39b05bac92be576897610d7d34e652c5baef75 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sun, 7 Feb 2016 12:12:24 -0500 Subject: [PATCH] =?UTF-8?q?Add=20array=20exercise=20from=20@ruipserra!!!?= =?UTF-8?q?=20=F0=9F=8E=86=F0=9F=8E=86=F0=9F=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Connects to #29. --- primitive_types/primitive_types3.md | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 primitive_types/primitive_types3.md diff --git a/primitive_types/primitive_types3.md b/primitive_types/primitive_types3.md new file mode 100644 index 0000000..c988d4f --- /dev/null +++ b/primitive_types/primitive_types3.md @@ -0,0 +1,45 @@ +// Create an array with at least 100 elements in it where the ??? is. +// Scroll down for hints! + +fn main() { + let a = ??? + + if a.len() >= 100 { + println!("Wow, that's a big array!"); + } else { + println!("Meh, I eat arrays like that for breakfast."); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + +// There's a shorthand to initialize Arrays with a certain size that does not +// require you to type in 100 items (but you certainly can if you want!) +// Check out the Primitive Types -> Arrays section of the book: +// http://doc.rust-lang.org/stable/book/primitive-types.html#arrays +// Bonus: what are some other things you could have that would return true +// for `a.len() >= 100`?