You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: intersection.rb
    path of file: ./repos/Ruby/data_structures/arrays
    
    the code of the file until where you have to start completion: # Challenge name: Intersection of two arrays ii
#
# Given two arrays, write a function to compute their inter
    
def intersect(arr1, arr2)
  result = []

  if arr1.length < arr2.length
    shorter = arr1
    longer = arr2
  else
    shorter = arr2
    longer = arr1
  end