Date: 2007-01-17 13:26
Sender: Eric Soderberg
This is caused due to how inject is being used
in Scruffy::Layers::Stacked.points(). Here's the relevant code:
longest_arr = layers.inject(nil) do |longest, layer|
longest = layer.points if (longest.nil? || longest.size <
layer.points.size)
end
On the first pass, longest is nil and gets assigned. If on the
second pass, layer.points.size >= longest.size, longest will
not be set and the block will return nil, re-setting longest
to nil. So, two layers, each with the same size, will result
in longest_arr being nil.
I've fixed this in my version via:
longest_arr = layers.inject(nil) do |longest, layer|
longest = layer.points if (longest.nil? || longest.size <
layer.points.size)
longest
end
|