Complete functions section
This commit is contained in:
parent
3ee889c050
commit
b5e81a915b
exercises/functions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
call_me();
|
||||
call_me(12);
|
||||
}
|
||||
|
||||
fn call_me(num: i32) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -7,7 +7,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn square(num: i32) -> i32 {
|
||||
num * num;
|
||||
num * num
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue