From: Jeremy Walker Date: 2012-05-22T23:34:17+09:00 Subject: Re: Disginguishing object types --f46d041824eeb278cf04c0a0e95e Content-Type: text/plain; charset=ISO-8859-1 On 22 May 2012 15:31, Doug Jolley wrote: > Frequently hash values are a mixture of object types. In the case at > issue, the various values of a particular hash may be either strings or > an array of strings. As I iterate through the hash to process the > respective values, I need to process a string value differently from the > way that I process a value that is an array. My question is: How do I > determine the object type of the respective values so that I can channel > it to the proper processing mechanism? > Probably the easiest way is: http://ruby-doc.org/core-1.9.3/Object.html#method-i-kind_of-3F You might also want to consider: http://ruby-doc.org/core-1.9.3/Object.html#method-i-respond_to-3F > > I apologize. I'm sure that I should be able to find the answer to this > question; but, I don't know what search criteria to use. > > Thanks for any input. > > ...doug > > -- > Posted via http://www.ruby-forum.com/. > > --f46d041824eeb278cf04c0a0e95e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On 22 May 2012 15:31, Doug Jolley <l= ists@ruby-forum.com> wrote:
Frequently hash values are a mixture of object types. =A0In the case at
issue, the various values of a particular hash may be either strings or
an array of strings. =A0As I iterate through the hash to process the
respective values, I need to process a string value differently from the way that I process a value that is an array. =A0My question is: =A0How do I=
determine the object type of the respective values so that I can channel it to the proper processing mechanism?

= Probably the easiest way is:
http://ruby-doc.org/core-1.9.3/Objec= t.html#method-i-kind_of-3F

You might also want to consider:
http://ru= by-doc.org/core-1.9.3/Object.html#method-i-respond_to-3F
=A0<= /div>

I apologize. =A0I'm sure that I should be able to find the answer to th= is
question; but, I don't know what search criteria to use.

Thanks for any input.

=A0 =A0 ...doug

--
Posted via http://= www.ruby-forum.com/.


--f46d041824eeb278cf04c0a0e95e--