title: inserting numbers into an array and checking
body: <p><strong>I wanted to insert numbers into this array, so that the user could choose how many to put until he wanted to leave.</strong></p>
  <ol>
  <li>The first problem - when the user puts in option 2 to exit, it still
  asks for the number once more before it exits, and also inserts it
  into the array.</li>
  <li>I tried to create a check so that if the user puts in a number
  already added previously, it won't be possible, but it's not working
  either.</li>
  </ol>
  <pre><code>numbers = []
  option = 1
  
  loop do
    if option == 1
      puts 'To enter a number type 1 - To exit type 2'
      option = gets.chomp.to_i
      
      print 'Type: '
      number_user = gets.chomp.to_i
      if number_user == numbers
        puts 'This number has already been entered!'
      elsif
        numbers &lt;&lt; number_user
      end
  
    elsif option == 2
      puts &quot;Bye!&quot;
      puts &quot;Entered numbers - #{numbers}&quot;
      return
    else
      puts &quot;Invalid option&quot;
      return
    end
  end
  </code></pre>