Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4619

How to remove square brackets (only) from an array? [duplicate]

$
0
0

I have an array stored in a constant like this:

FIELDS = ["first_name", "last_name", "occupation"]

I need to remove the square brackets only, it will look like this:

"first_name", "last_name", "occupation"

Does anyone have any ideas?

Thanks. :-)

For a little more context:

I have a complicated hash where I need to grab specific values from. My idea was to have the key of each value stored as an array, so I could then so

hash.values_at("first_name", "last_name", "occupation")

But that won't work with the square brackets from the array, hence my question!

I may be going around this the wrong way, however!


Viewing all articles
Browse latest Browse all 4619

Trending Articles