Array matching question

Hi,

What I am trying to achieve is a .match within an array.

array = {Danby:“347”, Jerry:"037, Mary:“221”}

#I want to get the numeric value if the text value is found in the
array.

if(/#input/.match(array) #this doesn’t work.

I know it’s something simple, I just can’t seem to find it yet.

Thanks in advance.

Markis Carrier wrote in post #1185489:

Hi,

What I am trying to achieve is a .match within an array.

array = {Danby:“347”, Jerry:"037, Mary:“221”}

That’s a hash, which is not an array. A " is missing too …

#I want to get the numeric value if the text value is found in the
array.

if(/#input/.match(array) #this doesn’t work.

What text value? “#input” doesn’t appear anywhere in your data
structure.
A ) is missing too …

I know it’s something simple, I just can’t seem to find it yet.

Thanks in advance.

Are you struggling with an XY problem?

“”"
You want to do X, and you think Y is the best way of doing so. Instead
of asking about X, you ask about Y.
“”"

Thanks for the reply Bonzo,

I guess it may be a little late to mention that I am new to Ruby…
My apologizes for the mistakes, I posted with my phone and didn’t have
the actual code with me.

As for the XY problem… You may be right.

I would like certain keywords to have a numeric value.
When a keyword is found, then the numeric value is returned.

Thanks!

Markis Carrier wrote in post #1185503:

Thanks for the reply Bonzo,

I guess it may be a little late to mention that I am new to Ruby…
My apologizes for the mistakes, I posted with my phone and didn’t have
the actual code with me.

As for the XY problem… You may be right.

I would like certain keywords to have a numeric value.
When a keyword is found, then the numeric value is returned.

Thanks!

Hash might help

“”"
A Hash is a dictionary-like collection of unique keys and their values.
Also called associative arrays, they are similar to Arrays, but where an
Array uses integers as its index, a Hash allows you to use any object
type.
“”"

(or navigate to the appropriate one for your ruby version)