auto arr = [1, 8, 17, 4, 23, 8, 8, 3, 13, 19, 8]; auto res = arr.removeElementsByContent(8); assert(res == [1, 17, 4, 23, 3, 13, 19]); auto lines = ["", "straw", "", "", "one more straw", "", ""]; auto straws = lines.removeElementsByContent(""); assert(straws == ["straw", "one more straw"]);
The function returns an array without unnecessary elements.