Forum: Ruby Accessing array elements case insensitively

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
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
This topic is locked and can not be replied to.