Forum: Ruby Accessing array elements case insensitively

Fb499bd36483d315b025b1bc6578fb4e?d=identicon&s=25 Sandhro Hadas (sandorhadasdig)
on 2017-01-26 11:56
There is some data which I usually access as (it comes from json
originally):
track = data['trackId']

Now sometimes I get 'Trackid' and 'TrackId' instead of 'trackId' so my
question is: how do I make this access to the element case insensitive?

Thanks :)
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2017-01-31 15:49
The title is misleading, since you don't have any array.

Now, as for your problem, you could for example use this:
https://github.com/junegunn/insensitive_hash
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.