Class: Array

Inherits:
Object show all
Defined in:
lib/nose/util.rb

Overview

Extend with some convenience methods

Instance Method Summary collapse

Instance Method Details

#longest_common_prefix(other) ⇒ Array<Object>

Find the longest common prefix of two arrays

Returns:



51
52
53
54
# File 'lib/nose/util.rb', line 51

def longest_common_prefix(other)
  fail TypeError unless other.is_a? Array
  (prefixes.to_a & other.prefixes.to_a).max_by(&:length) || []
end