class A
def p
puts "1"
end
end
a = A.new
a.p #=> "1"
class A
def p
puts "2"
end
end
a.p #=>"2"
Is this ruby property called “Open Class”?Is there any other language have this property?
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.
Yes, this is called open class in Ruby. Off the top of my head, other languages which have this property include Python and Smalltalk. Also, even though they don’t have classes, mutating a prototype object in ECMAScript, Self, Io and Ioke will have a similar effect.