Skip to content

Commit e56f874

Browse files
authored
update block format to match output, and remove trailing white spaces (#1751)
1 parent 9f85104 commit e56f874

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

concepts/enumeration/about.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Enumeration is the act of stepping through a collection (`Array`, `Hash`, etc) and performing some action on each object.
44

5-
Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more.
5+
Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more.
66
You'll most frequently see enumeration as the idiomatic way iterating through collections rather than using loops.
77

88
A simple enumeration to print each word in an array would look like this:
99

1010
```ruby
1111
words = %w[the cat sat on the mat]
12-
words.each do |word|
13-
puts word
12+
words.each do |word|
13+
puts word
1414
end
1515

1616
# Output:
@@ -22,14 +22,14 @@ end
2222
# mat
2323
```
2424

25-
In this example, we have called the `Array#each` method and passed in a _block_, which takes one parameter (`word`) and prints it.
25+
In this example, we have called the `Array#each` method and passed in a _block_, which takes one parameter (`word`) and prints it.
2626

27-
We can also chain enumerable methods.
27+
We can also chain enumerable methods.
2828
For example, we can chain `.with_index` onto `each` to print out the index of an object as well as it's value:
2929

3030
```ruby
3131
words = %w[the cat sat on the mat]
32-
list = words.map.with_index { |word, index| "#{index}: #{word}" }
32+
list = words.map.with_index { |word, index| "#{index}. #{word}" }
3333
puts list
3434

3535
# Output:

concepts/enumeration/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
Enumeration is the act of stepping through a collection (`Array`, `Hash`, etc) and performing some action on each object.
44

5-
Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more.
5+
Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more.
66
You'll most frequently see enumeration as the idiomatic way iterating through collections rather than using loops.
77

88
A simple enumeration making use of `map` and `with_index` looks like this:
99

1010
```ruby
1111
words = %w[the cat sat on the mat]
12-
list = words.map.with_index do |word, index|
13-
"#{index} #{word}"
12+
list = words.map.with_index do |word, index|
13+
"#{index}. #{word}"
1414
end
1515

1616
puts list

0 commit comments

Comments
 (0)