snippetrubyCritical
How can I delete one element from an array by value
Viewed 0 times
arraydeletehowfromvalueelementcanone
Problem
I have an array of elements in Ruby
I need to remove elements with value
How do I do that?
[2,4,6,3,8]I need to remove elements with value
3 for exampleHow do I do that?
Solution
I think I've figured it out:
a = [3, 2, 4, 6, 3, 8]
a.delete(3)
#=> 3
a
#=> [2, 4, 6, 8]Code Snippets
a = [3, 2, 4, 6, 3, 8]
a.delete(3)
#=> 3
a
#=> [2, 4, 6, 8]Context
Stack Overflow Q#10034678, score: 615
Revisions (0)
No revisions yet.