Guest User

Untitled

a guest
Apr 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. def explore(o, &b)
  2. explore(yield(o)) {|v|b.call(v)} if o
  3. end
  4.  
  5. block = Proc.new do |object|
  6. puts object.inspect
  7. object.methods.include?('first') ? object.first : nil
  8. end
  9.  
  10. explore([[:a, :b], [1, 2]]) {|obj| block.call(obj)}
Add Comment
Please, Sign In to add comment