0

I have an array of multiple types ( Int32 | Char | String ) and need to remove a specific element.

Is there a simple way to do that?

dkimot
  • 2,239
  • 4
  • 17
  • 25

2 Answers2

3

You may use Array(T).delete_at(index) to delete an element at a given index in your array, or Array(T).delete(obj) that deletes all elements in the array that are equal to obj

Robindar
  • 484
  • 2
  • 9
1

Inspired by Shree's now deleted answer

new_arr = arr.reject{ |element| element == "whatever"} or could use reject!

rogerdpack
  • 62,887
  • 36
  • 269
  • 388