Module: Algorithm
- Defined in:
- lib/ext/algorithm.rb
Class Method Summary collapse
Class Method Details
.follow(object, sym = nil, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/ext/algorithm.rb', line 3 def follow(object, sym = nil, &block) sym.nil? == block_given? or raise "Can't use both symbol and block" a = [] while object a << object object = block_given? ? yield(object) : object.send(sym) end a end |