copied from delete_if and reject!

```ruby
  def select!(&block)
    raise RuntimeError.new("can't modify frozen #{self.class}") if frozen?
    return self.enum_for(:select!) unless block
    prev_size = self.size
    self.keep_if(&block)
    return nil if prev_size == self.size
    self
  end

  def keep_if(&block)
    raise RuntimeError.new("can't modify frozen #{self.class}") if frozen?
    return self.enum_for(:keep_if) unless block
    i = 0
    c = 0
    sz = self.size
    while i < sz - c
      item = self[i + c]
      if !yield(item)
        c += 1
      else
        self[i] = item
        i += 1
      end
    end
    self.pop(c)
    self
  end
```