You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…Style/EachWithObject`
Fixrubocop#3736
`each_with_object` doesn't use block return value.
So, the return value can be removed.
```ruby
[1, 2, 3].inject({}) do |h, i|
h[i] = 1
# It can't be removed.
h
end
[1, 2, 3].each_with_object({}) do |i, h|
h[i] = 1
# It can be removed.
h
end
# Good code
[1, 2, 3].each_with_object({}) do |i, h|
h[i] = 1
end
```
…achWithObject`
Fix#3736
`each_with_object` doesn't use block return value.
So, the return value can be removed.
```ruby
[1, 2, 3].inject({}) do |h, i|
h[i] = 1
# It can't be removed.
h
end
[1, 2, 3].each_with_object({}) do |i, h|
h[i] = 1
# It can be removed.
h
end
# Good code
[1, 2, 3].each_with_object({}) do |i, h|
h[i] = 1
end
```
Expected behavior
[].inject({}){ |h, i| h }
should be corrected to[].each_with_object({}){ |i, h| }
Actual behavior
[].inject({}){ |h, i| h }
is corrected to[].each_with_object({}){ |i, h| h }
RuboCop version
Is that desired behaviour?
The text was updated successfully, but these errors were encountered: