I know what
class << self
does. But what is the underlying mechanism of this trick?
<< in Ruby is Binary Left Shift Operator
So we are doing binary left shift on class variable ?
Please clarify.
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’s not just binary left shift –
<<in Ruby is also the singleton class definition syntax. This syntax is used because all objects representing classes in Ruby are singleton classes.