I came across a usage such as:
InvalidRequest = Class.new(StandardError)
I am confused that:
- what’s the meaning to pass an argument to
Class.new? - What is the relationship between InvalidRequest, StandError and Class now?
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.
It sets up a class with the argument as the super class.
The argument is used as the superclass for a new anonymous class, which is returned.
InvalidRequestis aClasswhich inherits fromStandardError.It’s functionally equivalent to:
Just in a more functional programming style.