Explain how yield works and how it differs from calling a block via &block.call.
Last updated
yieldcalls the implicit block without allocating a Proc, so it is faster, but the block cannot be stored or forwarded.A
&blockparameter converts the block into a namedProcyou can call (block.call), store, or forward (other(&block)).Use
yieldby default and&blockonly when you must capture or pass the block on.
- 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
- https://www.reddit.com/r/rails/comments/1shfrbq/3_years_rails_dev_but_failed_basic_interview/