remove-method

remove from a List<T> within a foreach

I have code that I want to look like this: List<Type> Os; ... foreach (Type o in Os) if (o.cond) return; // quiting early is important for my case! else Os.Remove(o); ... // other code This doesn't work because you can't remove from a list inside a foreach over that list: Is there a common way to solve th...

Ruby - How to remove a setter on an object

Given a class like this: class B class << self attr_accessor :var end end Suppose I can't modify the original source code of class B. How might I go about removing the setter on the class variable var? I've tried using something like B.send("unset_method", "var="), but that doesn't work (nor does remove_method, or ov...