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: good_pairs.rb
    path of file: ./repos/Ruby/data_structures/arrays
    
    the code of the file until where you have to start completion: # Challenge name: Number of good pairs
#
# Given an array of integers nums.
# A pair (i,j) is 
    
def num_identical_pairs(nums)
  count = 0
  nums.each_with_index do |num, i|
    target = num
    nums.each_with_index do |num, j|
      next if i >= j

      count += 1 if num == target
    end
  end
  count
end