i have an array of arrays. from this i want to eliminate the empty arrays.
iam using reject!(&:empty?) method. but it is giving me unexpected results.
2.2.2 :306 > array = ["yes","yes","yes"]
=> ["yes", "yes", "yes"]
2.2.2 :307 > array.split("no")
=> [["yes", "yes", "yes"]]
2.2.2 :308 > array.split("no").reject!(&:empty?)
=> nil
2.2.2 :309 > array_with_no = ["yes","yes","yes","no"]
=> ["yes", "yes", "yes", "no"]
2.2.2 :310 > array_with_no.split("no")
=> [["yes", "yes", "yes"], []]
2.2.2 :311 > array.split("no").reject!(&:empty?)
=> nil
2.2.2 :312 > array_with_no.split("no").reject!(&:empty?)
=> [["yes", "yes", "yes"]]
2.2.2 :313 >
i want the result where when there is no empty array to eliminate, then it should return the same array instead of returning nil