basic/flow-control #660
Replies: 36 comments 46 replies
-
这里是因为所有权吗?是的话可能要强调一下 好像没有强调么,到底是不是呢? |
Beta Was this translation helpful? Give feedback.
-
for循环:(这里是因为所有权吗?是的话可能要强调一下) 这个信息是MR的评论吧?😂 |
Beta Was this translation helpful? Give feedback.
-
break的嵌套和标签的功能也列一下比较好吧:) |
Beta Was this translation helpful? Give feedback.
-
为啥到这里就没评论了,我还想看看评论 |
Beta Was this translation helpful? Give feedback.
-
为什么 for 循环中会发生所有权的移动而 while 循环不会呢?是因为 for ... in ... 的缘故吗? |
Beta Was this translation helpful? Give feedback.
-
没有switch语法吗? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
这句话没有理解, 下面的代码运行没问题。 let my_array = [1, 2, 3];
for n in my_array {
print!("{}\t", n);
print!("{:?}", my_array);
}
for n in my_array {
print!("{}\t", n);
print!("{:?}", my_array);
} |
Beta Was this translation helpful? Give feedback.
-
想问问break后面加和不加分号的区别 |
Beta Was this translation helpful? Give feedback.
-
作为一名几年python开发者学到这里,熟悉感拉满,处处似曾相识,预言以后rust一定会成为现在广泛开发者的第二语言甚至是第一语言。 |
Beta Was this translation helpful? Give feedback.
-
这里没有介绍到 label |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
我怀疑这两种循环在数组长度可知的情况下,编译后的效率将是一样的,不建议按照Python这类逐行解释的语言的思路来看这里的性能问题 当然,使用第二种遍历数组肯定是更安全的
|
Beta Was this translation helpful? Give feedback.
-
fn main() {
let a = [10, 20, 30, 40, 50];
for element in a.iter() {
println!("the value is: {}", element);
}
} for循环里面的, 正常不应该是 *element 吗,element不应该是指针吗。 |
Beta Was this translation helpful? Give feedback.
-
不知道为什么作者很喜欢对比 JavaScript,按理说 rust 这种系统级语言应该跟 c++ 对比吧,当然纯粹语法层面都可以比较啦。。 const arr = [3, 5, 7];
arr.foo = "hello";
for (const i in arr) {
console.log(i);
}
// "0" "1" "2" "foo"
for (const i of arr) {
console.log(i);
}
// Logs: 3 5 7 |
Beta Was this translation helpful? Give feedback.
-
is there any programing language not supporting 'if' and 'else'? ChatGPT: Assembly Languages: Low-level assembly languages often lack high-level control structures like if and else. Instead, they rely on jump and branch instructions for conditional execution. |
Beta Was this translation helpful? Give feedback.
-
笔记:只有loop可以用break返回value,while和for只能返回() |
Beta Was this translation helpful? Give feedback.
-
有个疑问,fn main() {
} |
Beta Was this translation helpful? Give feedback.
-
提问: |
Beta Was this translation helpful? Give feedback.
-
这方面 还是go简单。 |
Beta Was this translation helpful? Give feedback.
-
+= 也是循环结束后才生效 |
Beta Was this translation helpful? Give feedback.
-
这里是不是缺了个break和continue标签的用法,看练习里有 |
Beta Was this translation helpful? Give feedback.
-
希望可以讲讲循环标签的用途 |
Beta Was this translation helpful? Give feedback.
-
while 和 loop 都不要求所有权吗?从课后练习看视乎是这样的。 |
Beta Was this translation helpful? Give feedback.
-
这里比较喜欢golang语言的大道至简,while, loop 都可以使用都集中在 for 中 |
Beta Was this translation helpful? Give feedback.
-
while: 兄弟你再坚持一下,我快出来了🤫🤫 |
Beta Was this translation helpful? Give feedback.
-
while true {} 这货怎么了? |
Beta Was this translation helpful? Give feedback.
-
basic/flow-control
https://course.rs/basic/flow-control.html
Beta Was this translation helpful? Give feedback.
All reactions