---
title: "Membuat Hash dari Enumerable (Rails 6.0)"
description: "Method baru yang memungkinkan Anda membuat Hash dari Enumerable:"
canonical: https://oozou.com/til/create-a-hash-from-an-enumerable-rails-6-0-6
locale: id
date: 2020-10-13
topic: ruby-on-rails
---

# Membuat Hash dari Enumerable (Rails 6.0)

> Method baru yang memungkinkan Anda membuat Hash dari Enumerable:

Published: 2020-10-13 · Topic: [ruby on rails](https://oozou.com/id/til-topics/ruby-on-rails) ([markdown](https://oozou.com/id/til-topics/ruby-on-rails.md))

Method baru yang memungkinkan Anda membuat Hash dari Enumerable:

```ruby
%w(driver owner drivy).index_with(nil)
# => { 'driver' => nil, 'owner' => nil, 'drivy' => nil }

%w(driver owner drivy).index_with { |role| delta_amount_for(role) }
# => { 'driver' => '...', 'owner' => '...', 'drivy' => '...' }
```

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/id/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
