Compare instance_eval and class_eval. When would you use each?
Last updated
instance_evalsetsselfto one object, so adefinside creates a singleton method on that object only. Use it for per-object config and DSL builder blocks.class_eval(aliasmodule_eval) runs as if inside the class body, sodefcreates an instance method shared by all instances.Use
class_evalto reopen or patch a class dynamically, especially when the class is held in a variable.
- https://www.turing.com/interview-questions/ruby
- https://www.youtube.com/watch?v=lkunzd5uDrw
- https://blog.jacobvosmaer.nl/0004-ruby-scheduler-interaction/
- https://wohotech.in/coding/top-java-interview-questions
- https://jetthoughts.com/blog/ruby-3-4-yjit-performance-guide/
- https://speed.ruby-lang.org/
- https://flexiple.com/python/interview-questions