---
title: "สร้าง Hash จาก Enumerable (Rails 6.0)"
description: "method ใหม่ที่ช่วยให้คุณสร้าง Hash จาก Enumerable ได้:"
canonical: https://oozou.com/til/create-a-hash-from-an-enumerable-rails-6-0-6
locale: th
date: 2020-10-13
topic: ruby-on-rails
---

# สร้าง Hash จาก Enumerable (Rails 6.0)

> method ใหม่ที่ช่วยให้คุณสร้าง Hash จาก Enumerable ได้:

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

method ใหม่ที่ช่วยให้คุณสร้าง Hash จาก 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/th/contact

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