-- Practice Midterm Solution Thread
Arun Murugan, Luksawee
Q: 11
Early basic: the scope is the single global scope; x1, x2
Fortran: The scope is both global and local scope
Ex. For the global
Ex. For the local
Rust:
Let introduce the scope that visible on the stack unless another let call with the same variable name appear on the stack before the previous one. The newest call with that variable name is token. The another let call with that the same variable name will be showdown
Ex.
let a = 1
let b = 2; β> this will be showdown with 5
let b = 5;
println!(β{}β, b) β> It should get the 5
borrowing ru, it will be able to get the refernce, but it will not get the ownership.
fn main() {
let I = 5;
print_i(&i);
}
fn print_i(i:: i32) {
println!(βi = {} β, i);
}
(
Edited: 2021-10-11)
Arun Murugan, Luksawee
Q: 11
Early basic: the scope is the single global scope; x1, x2
Fortran: The scope is both global and local scope
Ex. For the global
Ex. For the local
Rust:
Let introduce the scope that visible on the stack unless another let call with the same variable name appear on the stack before the previous one. The newest call with that variable name is token. The another let call with that the same variable name will be showdown
Ex.
let a = 1
let b = 2; β> this will be showdown with 5
let b = 5;
println!(β{}β, b) β> It should get the 5
borrowing ru, it will be able to get the refernce, but it will not get the ownership.
fn main() {
let I = 5;
print_i(&i);
}
fn print_i(i:: i32) {
println!(βi = {} β, i);
}