t_wの輪郭

tup

2022/2/16 23:23:00

タプル

    //値取り出し
    {
        let x: (i32, f64, u8) = (500, 6.4, 1);
        println!("x.0: {}, x.1: {}, x.2: {}", x.0, x.1, x.2);
        //x.0: 500, x.1: 6.4, x.2: 1
    }

    //パターンマッチング
    {
        let tup = (500, 6.4, 1);
        let (x, y, z) = tup;
        println!("The value of x, y, z is: {}, {}, {}", x, y, z);
        //The value of x, y, z is: 500, 6.4, 1
    }