Please help me with this piece of code i can't understand

Why does the second print returns false[9, 33] ?

fn main() {
    let a = vec![9,33,11];
    let b = match a.get(10) {
            None => false,
            _ => true
    };
    print!("{}", b);            // THIS IS THE FIRST PRINTLN
    let x = &a[0..2];
    print!("{:?}", x);          // THIS IS THE SECOND PRINTLN
}```


I expected to return [9, 33]

If i remove the first print then it returns [9, 33]

Why does the first print provokes this strange behavior ?

Um. You printed false then printed [9, 33], of couse you get false[9, 33].

Did you meant to use println instead of print?

1 Like

Thank you ! I am so stupid :smile:

Couldn't see it, it was right in front of me :crazy_face:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.