Ruby Array : Deleting Elements
Deleting Array Elements
chars = ["a", "b", "c"] => ["a", "b", "c"]Approach 1 : Using index
colors.delete_at(1) => "b" colors => ["a", "c"]
Approach 2: Using the actual value
colors = ["a", "b", "c"] => ["a", "b", "b"]
colors.delete("b") => "b" colors => ["a", "c"]
Comments
Post a Comment