This question does not appear to be about programming within the scope defined in the help center.
Closed 11 years ago.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(17)
“through”和“over”是无用的副词。
示例:
迭代此集合时,我的代码抛出错误。
此代码迭代集合。
您的任务是编写迭代集合的代码。
这就像说“北上”或“南下”。 “上”和“下”是没有用的。相反,你应该说:“我要去北方过夏天。”或“在南方,他们种植棉花。”
"through" and "over" are useless adverbs.
Examples:
It's like saying "up north" or "down south". "up" and "down" are useless. Instead you should say, "I am going north for the summer." or "In the south, they grow cotton."
没有对错之分,只是一些统计数据:
Google 统计数据于 2018 年 4 月 25 日更新。后续搜索显示结果不稳定。
Github 统计数据于 2018 年 4 月 25 日更新。仅计算代码出现次数。
Not right or wrong, just some stats:
Google stats updated on 4/25/2018. Subsequent searches show that results are unstable.
Github stats updated on 4/25/2018. Only code occurrences are counted.
我认为这取决于介词的宾语;你遍历迭代器,遍历集合,遍历容器,遍历列表,遍历范围等,但是你遍历列表(的内容),遍历容器(的元素),遍历(的元素) )范围,通过集合(的元素)等。在几乎所有情况下,它们都是可以互换的;我唯一会使用“over”而不是“through”的地方是关于迭代器本身;但对于任何可迭代对象,我会使用“over”或“through”。
I think it depends on the object of the preposition; you iterate over the iterator, over the collection, over the container, over the list, over the range, etc. but you iterate through (the contents of) the list, through (the elements of) the container, through the (elements of ) the range, through (the elements of) the collection, etc. In almost all cases they are interchangeable; the only place I would use "over" but not "through" is with respect to the iterator, itself; but for any iterable object, I'd use either "over" or "through".
我会说迭代,这是我一直看到的编写方式。
I would say iterate over, and this is the way I've always seen it written.
两者本质上意思是一样的!
因此,您可以自由选择适合您的。
Both essentially mean the same!
So, you are free to choose whichever suits you.
我总是说“迭代over”,因为它强调了一个(相对重要的)事实,即迭代器本身不包含在作为迭代主题的容器中。
对我来说,说“迭代”意味着依次查看容器的每个元素,但这并不是真正发生的情况。
相反,“迭代”对我来说意味着依次接收容器中每个元素的外部句柄,这实际上就是正在发生的事情。
然而,“迭代”并没有什么问题,任何理解迭代器的人都一定会理解这两个短语。
I would always say "iterate over" because it emphasizes the (relatively important) fact that the iterators themselves are not contained in the container that is the subject of the iteration.
To say "iterate through", to me, would imply that one were looking at each element of the container in turn, which is not really what is happening.
In contrast, saying "iterate over" implies to me that one is receiving an external handle to each element of the container in turn, which is really what is happening.
However, there's nothing wrong with "iterate through", and anyone who understands iterators would surely understand both phrases.
从技术上讲,这可能只是“迭代”时期。但无论哪种情况,你的意思都很明显。
Technically it's probably just "iterate" period. But its obvious what you mean in either case.
我使用“循环”。简单的。
I use "loop over". Simple.
System.Collections.Generic.IEnumerator GetEnumerator() 的摘要文本表示:
就我个人而言,我说通过......但实际上我认为您使用哪一个并不重要。
The summary text for System.Collections.Generic.IEnumerator GetEnumerator() says:
Personally I say through ... but really I don't think it matters which one you use.
重要的是迭代,你用什么填充物并不重要。
The important word is iterate, what filler you place with it really doesn't matter.
我想象“迭代”某些东西,就像我做文件柜一样。也许这只是个人喜好,考虑到我的心理形象 - 我认为“迭代”是更常见的用法。
I picture "iterating through" something, the way I do a file cabinet. Maybe it's just personal preference though, given my mental image - I think "Iterate Over" is the more common usage.
我随机使用两者,有时在同一个句子中使用。删除连接词是一种糟糕的语法,而且没有任何意义。
I use both at random, sometimes in the same sentence. Dropping the connecting word is bad grammar and neither is meaningful.
我认为它们在大多数实际用途中是可以互换的,但在我的评论中,我个人倾向于使用它们,但有一个小小的区别:我将“迭代”某些东西解释为类似于你会说“我会查看它”的意思”。也就是说,这不是一次深入的检查:您正在浏览它以寻找某些东西。相反,“迭代”就是有目的地遍历每一项。
因此,如果我只是在列表中搜索一个项目,我会说我正在“迭代”列表......如果我对每个项目应用一些转换,那么它将是“迭代”。
I think they are interchangeable for most practical purposes, but in my comments I personally tend to use them with a small distinction: I interpret to "iterate over" something to be similar to the sense that you would say "I'll look over it". That is, it's not a deep inspection: you are browsing over it looking for something. Conversely, to "iterate through" is to go through each and every one purposefully.
So if I was just searching for one item in a list I would say I was "iterating over" the list.....if I was applying some transformation to each item, it would be "iterate through".
字典说“迭代”是一个及物动词,意思是“再说一遍或做一次;重复”。
你会“重复”刚刚说过的话,还是“重复”一遍吗?我认为你只需重复一遍即可。或者只是简单地迭代它,如您所愿。
话虽如此,如果您使用“迭代”作为“循环”的某种同义词......一次一次迭代地循环数据,那么也许您正在“迭代”。这是一个雷区!
Dictionary says "iterate" is a transitive verb meaning to "say or do again; repeat".
Would you "repeat over" something you just said, or "repeat through" it? I think you'd just plain repeat it. Or just plain iterate it, as you prefer.
Having said that, if you're using "iterate" as some kind of synonym for "loop"... looping through data one iteration at a time, perhaps, then maybe you ARE "iterating through". This is a minefield!
两者都是修辞性的同义反复。你应该删除多余的介词。如在
或者,也许
Either is a rhetoical tautology. You should remove the superfluous preposition. As in
or, perhaps
Common Lisp 的 LOOP 宏使用
for list 中的元素
,但for element across array
(这是不同的,因此编译器可以生成更高效的代码......是的,这很奇怪),建议介词并不是那么重要。Common Lisp's LOOP macro uses
for element in list
, butfor element across array
(it's different so the compiler can generate more efficient code ... yeah, it's weird), suggesting that the preposition isn't really that important.有一个更好的方法。
就像“has”这个词一样,它经常可以将整个句子简化为一个单词。
为什么不保持 iterate 进行迭代,就像这样 ->圆形、三角形、八边形、五边形、六边形。
There is a better way.
It's like the word "has", that can so often reduce a whole sentance to a single word.
Why not keep iterate for iteration, like this -> circle, triangle, octagon, pentagon, hexagon.