Sha256: caaf9989eefd38a58045748c77ea1ad8a54ff65d7f60e94d5f41ecf3f871c110

Contents?: true

Size: 305 Bytes

Versions: 35

Compression:

Stored size: 305 Bytes

Contents

class Array
 def select!
  where_at = 0
  total = length
  each{|member|
    if yield(member)
      self[where_at] = member
      where_at += 1
    end
  }
  while(where_at < total)
    self[where_at] = nil
    where_at += 1
  end
  compact! # there may be a better way...
  self
 end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
sane-0.23.2 lib/sane/array_select_bang.rb
sane-0.23.1 lib/sane/array_select_bang.rb
sane-0.23.0 lib/sane/array_select_bang.rb
sane-0.22.0 lib/sane/array_select_bang.rb
sane-0.21.3 lib/sane/array_select_bang.rb
sane-0.21.2 lib/sane/array_select_bang.rb
sane-0.21.0 lib/sane/array_select_bang.rb
sane-0.20.3 lib/sane/array_select_bang.rb
sane-0.20.2 lib/sane/array_select_bang.rb
sane-0.20.1 lib/sane/array_select_bang.rb
sane-0.20.0 lib/sane/array_select_bang.rb
sane-0.19.1 lib/sane/array_select_bang.rb
sane-0.19.0 lib/sane/array_select_bang.rb
sane-0.18.0 lib/sane/array_select_bang.rb
sane-0.17.1 lib/sane/array_select_bang.rb