Skip to content

tutorial about match can be misunderstood about the role of the "my_number" #13571

Closed
@zookoatleastauthoritycom

Description

Reading http://static.rust-lang.org/doc/master/tutorial.html#pattern-matching, my partner copied the example code:

match my_number {
 0 => { println!("zero") }
  _ => { println!("something else") }
}

into her program, but then was unsure what to do, possibly because she thought that the example code above would define a variable named "my_number". I suggested to her that the tutorial could instead suggest:

fn f(my_number: int) -> void {
    match my_number {
     0 => { println!("zero") }
      _ => { println!("something else") }
    }
}

and that made sense to her.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions