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: answer.rb
    path of file: ./repos/hitobito/app/models/event
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

#  Copyright (c) 2012-2020, Jungwacht Blauring Schweiz. This file is part of
#  hitobito and licensed un
    
  def valid_index_based_values(index_array, valid_range)
    indexes = index_array.map do |index|
      if valid_range.include?(index)
        question.choice_items[index]
      end
    end.compact

    indexes.present? ? indexes.join(', ') : nil
  end