Using `inject`, `unless`, and `next` to determine the minimum value
问题 I have this code: def test(vertices, distances) until vertices.empty? nearest_vertex = vertices.inject do |a, b| p "a = #{a}: b = #{b}" p "distances[a] = #{distances[a]}, distances[b] = #{distances[b]}" next b unless distances[a] #next b if distances[a] == true next a unless distances[b] #next a if distances[b] == true next a if distances[a] < distances[b] p "b = #{b}" b end p "nearest_vertex = #{nearest_vertex}" vertices.delete nearest_vertex end end vertices = [1, 2, 3, 4, 5, 6] distances =