The source code to demonstrate the if let statement is given below. The given program is compiled and executed successfully.
// Rust program to demonstrate the
// example of if let statement
fn main()
{
let num: f32 = 16.0;
let result = if let 16.0=num{
"Hello"
}
else{
"Hiii"
};
println!("{}",result);
}
Output:
Hello
Explanation:
Here, we created a variable num of f32 type with an initial value of 16.0. Then we compared the value of num using the if let statement and return the string value. After that, we printed the returned value.
Program/Source Code:
The source code to demonstrate the if let statement is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a variable num of f32 type with an initial value of 16.0. Then we compared the value of num using the if let statement and return the string value. After that, we printed the returned value.
need an explanation for this answer? contact us directly to get an explanation for this answer