Tobias
Tobias

Reputation: 21

Hash#key for 1.8.6

Greetings,

I am trying to make my 1.9.1 source 1.8.6 compatible. I recognized that there's no Hash#key method. Any idea or method how to solve that?

Thanks!

Tobias

Upvotes: 2

Views: 236

Answers (2)

Marc-André Lafortune
Marc-André Lafortune

Reputation: 79562

Use Hash#index, or require "backports/1.9.1/hash/key".

You can also require 'backports' and most of the API changes from 1.8.6 to 1.9.2 will be backported and available in Ruby 1.8.6 (including Hash#key, of course).

Upvotes: 4

sepp2k
sepp2k

Reputation: 370212

In ruby 1.8 that method is called index.

Upvotes: 2

Related Questions