What’s the difference between the class and type methods in Ruby? I’ve noticed that type works to find the type of some classes but not others.
What’s the difference between the class and type methods in Ruby? I’ve noticed that
Share
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.
The key difference is that
Object#typeis deprecated. From the RDoc for Object#type:Here’s why you should use
Object#class:In reality, you probably want to use
Object#respond_to?instead of checking for the class of an object in most cases.