remove

--

remove value from given collection


Parameters

remove collection :string :literal :pathliteral :dictionary :object :block
       value :any

Attributes

key remove dictionary key
once remove only first occurence
index remove specific index
prefix remove first matching prefix from string
suffix remove first matching suffix from string
instance remove an instance of a block, instead of its elements.

Returns

  • :string
  • :dictionary
  • :block
  • or  :nothing

Examples

copy
remove "hello" "l" ; => "heo" print "hello" -- "l" ; heo remove [1 2 3 4] 4 ; => [1 2 3]

copy
str: "mystring" remove 'str "str" print str ; mying

copy
remove.key #[name: "John" surname: "Doe"] "surname" ; => #[name: "John"]

copy
print remove.once "hello" "l" ; helo ; Remove each element of given block from collection once remove.once [1 2 [1 2] 3 4 1 2 [1 2] 3 4] [1 2] ; [[1 2] 3 4 1 2 [1 2] 3 4]

copy
remove.index: 2 "Ruby" "u" ; => Rby remove.index: 2 "Ruby" "a" ; => Ruby

copy
remove.prefix "--empty --flag" "--" ; => "empty --flag" remove.suffix "test.txt file.txt" ".txt" ; => "test.txt file"

copy
remove.instance [1 [6 2] 5 3 [6 2] 4 5 6] [6 2] ; => [1 5 3 4 5 6] remove.instance.once [1 [6 2] 5 3 [6 2] 4 5 6] [6 2] ; => [1 5 3 [6 2] 4 5 6]

Related