fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,29 @@
---
title: Ruby For Loops
localeTitle: Ruby For循环
---
## Ruby For循环
Ruby for循环用于循环或迭代许多元素并执行每个元素的代码块。 For循环通常用在数组上。请参阅[Ruby Arrays](https://github.com/freeCodeCamp/guides/blob/master/src/pages/ruby/ruby-arrays/index.md)部分。
for循环只是循环或迭代元素的一个例子。下面是for循环的示例
```
for element in array do
puts element
end
```
在Ruby中有许多不同的方法可以执行for循环或循环另一个例子是
```
element.each do |element|
puts element
end
```
这将获得与上述for循环完全相同的结果但是它使用Array的内置方法更整洁更高效。
为了更进一步,我们可以通过以下方式编写上述循环:
```
element.each do { |element| puts element }
```