Skip to content
On this page

原生类型1: exercises/primitive_types/primitive_types1.rs

题目

rust
// primitive_types1.rs
//
// Fill in the rest of the line that has code missing! No hints, there's no
// tricks, just get used to typing these :)
//
// Execute `rustlings hint primitive_types1` or use the `hint` watch subcommand
// for a hint.

// I AM NOT DONE

fn main() {
    // Booleans (`bool`)

    let is_morning = true;
    if is_morning {
        println!("Good morning!");
    }

    let // Finish the rest of this line like the example! Or make it be false!
    if is_evening {
        println!("Good evening!");
    }
}

填充代码中缺失的行。

题目解析

注释里面说,需要补充这一行代码,并且让它是false。

所以我们需要对is_evening进行初始化和赋值。

rust
fn main() {
    // Booleans (`bool`)

    let is_morning = true;
    if is_morning {
        println!("Good morning!");
    }

    let // Finish the rest of this line like the example! Or make it be false!  
    let is_evening = false; // Finish the rest of this line like the example! Or make it be false! 
    if is_evening {
        println!("Good evening!");
    }
}

参考资料

Powered by VitePress