Ad
  • Custom User Avatar

    That is an extra fail-safe. In the chance that strarr.each_cons(k).map(&:join).max_by(&:length) returns nil, which it will if the array strarr is empty, then an empty string will be returned. Since nil is falsey, '' (the empty string) will be returned when the || expression is evaluated on the last line—since strings are considered truthy. The first line of the method should handle cases where strarr points to an empty string, but it's not bad to have a back up.