Whats the difference between class_eval and class << className?
问题 I am a Ruby starter. I found both of these are quite similar (in output), but i couldn't understand the difference in the below context. For example, I have a class class Say def self.hello puts "hello" end end and can be extended like this class << Say def hi puts "hi" end end and also like this Say.class_eval do def self.bye puts "bye" end end When should I use << and when class_eval ? 回答1: class_eval doesn't really have anything to do with class << className . A.class_eval do ... end is