Slight refactor:

```ruby
@grouped_unread_notification_counts = Hash.new(0)
current_user.unread_notifications.group_by(&:type)
  .each_with_object(@grouped_unread_notification_counts) {|(type, notifications), counts|
  counts[type] = notifications.count
}
```
(Untested but should work).