mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix example of index_with
- Clarify executor of `public_send`. - Do not wrap `Interval.all_day` into [] since an array is expected as a returned value. Related to #32523. [ci skip]
This commit is contained in:
parent
3573005517
commit
1ae1099ed4
1 changed files with 2 additions and 2 deletions
|
@ -2045,10 +2045,10 @@ The method `index_with` generates a hash with the elements of an enumerable as k
|
||||||
is either a passed default or returned in a block.
|
is either a passed default or returned in a block.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
%i( title body created_at ).index_with { |attr_name| public_send(attr_name) }
|
%i( title body created_at ).index_with { |attr_name| post.public_send(attr_name) }
|
||||||
# => { title: "hey", body: "what's up?", … }
|
# => { title: "hey", body: "what's up?", … }
|
||||||
|
|
||||||
WEEKDAYS.index_with([ Interval.all_day ])
|
WEEKDAYS.index_with(Interval.all_day)
|
||||||
# => { monday: [ 0, 1440 ], … }
|
# => { monday: [ 0, 1440 ], … }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue