Complete functions section

This commit is contained in:
Paul Czeresko 2019-07-20 11:46:11 -04:00
parent 3ee889c050
commit b5e81a915b
5 changed files with 8 additions and 4 deletions

View file

@ -1,6 +1,10 @@
// functions1.rs
// Make me compile! Scroll down for hints :)
fn call_me() -> () {
println!("I have been called!");
}
fn main() {
call_me();
}

View file

@ -5,7 +5,7 @@ fn main() {
call_me(3);
}
fn call_me(num) {
fn call_me(num: i32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}

View file

@ -2,7 +2,7 @@
// Make me compile! Scroll down for hints :)
fn main() {
call_me();
call_me(12);
}
fn call_me(num: i32) {

View file

@ -9,7 +9,7 @@ fn main() {
println!("Your sale price is {}", sale_price(original_price));
}
fn sale_price(price: i32) -> {
fn sale_price(price: i32) -> i32{
if is_even(price) {
price - 10
} else {

View file

@ -7,7 +7,7 @@ fn main() {
}
fn square(num: i32) -> i32 {
num * num;
num * num
}