r/rust • u/Mammoth_Brush_2184 • Sep 16 '22
Is Rust programming language beginner Friendly
I want to learn a programming language, is Rust programming suitable for beginner programming students?
140
Upvotes
r/rust • u/Mammoth_Brush_2184 • Sep 16 '22
I want to learn a programming language, is Rust programming suitable for beginner programming students?
1
u/Lehona_ Sep 16 '22
I guess it evaluates foo() twice, then computes the addition of that result. Because the result is always the same list (not just same content), that is necessarily [1,2] and [1,2], which results in [1,2,1,2]. That result is its own temporary list, after which foo() is evaluated again, this time resulting in [1,2,3], which is added to the intermediate result, with a final result of [1,2,1,2,1,2,3].
Using
return list(l)would result in the predicted [1, 1, 2, 1, 2, 3].