How to rewrite this line using an iterator?
actor.inspect if actor.is_a? Array || actor.is_a? Hash
My attempt that dosen’t work:
actor.inspect if [Array, Hash].each { |c| actor.is_a? c }
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to match exact classes (and not descendants), you can use:
I think you should explain what exactly you need to achieve. Perhaps the only thing you need to check is if your object is an
Enumerableor not, or even if itrespond_to?some particular method.