0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Rust 超入門 → 列挙型

Last updated at Posted at 2022-09-30

列挙型

列挙型は生成したデータ型です。列挙型はenumを使って定義します。列挙子指定は::を使います。

enum Language_version {
    java,
    php,
    Ruby,
    python,
    nodejs,
}

列挙型の値

enum Language_version {
    java(String),
    php(String),
    Ruby(String),
    python(String),
    nodejs(String),
}

fn main() {
    let j = Language_version::java("11".to_string());
    let p = Language_version::java("8.0".to_string());
    let r = Language_version::java("2.7".to_string());
    let y = Language_version::java("3.9".to_string());
    let n = Language_version::java("17-3".to_string());

    println("{:?} {:?} {:?} {:?} {:?} ", j, p, r, y, n);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?