B Seven B Seven - 7 months ago 36
Ruby Question

What is the opposite of Array#reject in ruby?

Is seems that it might be

keep_if
.

If so, why isn't it called
keep
?

Answer
  • The opposite of reject is select (returning a new array)
  • The opposite of reject! is select! (editing the array in place)
  • The opposite of keep_if is delete_if (editing the array in place)
Comments