From: Alex Stahl Date: 2010-09-17T03:06:20+09:00 Subject: Traversing a friend graph - the ruby way? Recently, I needed to write some code to traverse friend graphs on my website. Due to my C++ background, I used recursion: def traverse(user, depth, origin=nil) @hi5 = Hi5fbapi.new @api_key, @secret if depth > 0 friends = @hi5.get_friends(user) friends.delete origin if friends.include? origin depth -= 1 friends.each do |friend| traverse(friend, depth, user) end end end But as I continue to learn the finer points of ruby, I can't help but think there's a more ruby-oriented way to do this. Any suggestions? Thanks, Alex