---
title: "带序号循环Hash"
author: "clark1231"
date: "2011-12-16T09:19:33Z"
tags: ["Ruby"]
categories: ["编程语言"]
slug: "hash"
draft: false
lastmod: "2011-12-16T09:19:33Z"
id: 1313504
url: "https://caok1231.iteye.com/blog/1313504"
---

```
hash.keys.each_with_index do |key, index|
   value = hash[key]
   print "key: #{key}, value: #{value}, index: #{index}\n"
   # use key, value and index as desired
end
```