Posted By

rkumar on 09/28/10


Tagged

meta


Versions (?)

yield or eval


 / Published in: Ruby
 

  1. def yield_or_eval &block
  2. return unless block
  3. if block.arity > 0
  4. yield self
  5. else
  6. self.instance_eval(&block)
  7. end
  8. end
  9.  

Report this snippet  

You need to login to post a comment.