Sha256: daa4b08514792d378c3841bccde9506bf799fc0cc1cc096faa22cdd40db35374
Contents?: true
Size: 521 Bytes
Versions: 4
Compression:
Stored size: 521 Bytes
Contents
class Array # Remove the first instance of an item from an array. # **Note**: this will mutate the reciever. # # @param item [Object] # @return [self] def remove_first!(item) return self if self.length == 0 index = self.index(item) self.delete_at(index) if index return self end # Return a copy of an array the first instance of a given item removed. # # @param item [Object] # @return [self] def remove_first(item) return self.dup.tap { |s| s.remove_first!(item) } end end
Version data entries
4 entries across 4 versions & 1 rubygems