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.
B01ecb9fbeb507d7ad2d631b92b86a35?d=identicon&s=25 Sandhro H. (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 :)
3a81ced4012650ca2004c9bff7b18202?d=identicon&s=25 Ronald F. (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.