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.25.8 lib/sane/array_select_bang.rb
sane-0.25.7 lib/sane/array_select_bang.rb
sane-0.25.6 lib/sane/array_select_bang.rb
sane-0.25.5 lib/sane/array_select_bang.rb
sane-0.25.4 lib/sane/array_select_bang.rb
sane-0.25.3 lib/sane/array_select_bang.rb
sane-0.25.2 lib/sane/array_select_bang.rb
sane-0.25.1 lib/sane/array_select_bang.rb
sane-0.25.0 lib/sane/array_select_bang.rb
sane-0.24.6 lib/sane/array_select_bang.rb
sane-0.24.5 lib/sane/array_select_bang.rb
sane-0.24.4 lib/sane/array_select_bang.rb
sane-0.24.3 lib/sane/array_select_bang.rb
sane-0.23.6 lib/sane/array_select_bang.rb
sane-0.24.2 lib/sane/array_select_bang.rb
sane-0.24.1 lib/sane/array_select_bang.rb
sane-0.24.0 lib/sane/array_select_bang.rb
sane-0.23.5 lib/sane/array_select_bang.rb
sane-0.23.4 lib/sane/array_select_bang.rb
sane-0.23.3 lib/sane/array_select_bang.rb