How do I declare an array when I don’t know the length until run time?

As of Delphi 4, Delphi supports dynamic arrays. You can modify their sizes at run time and they will retain the data you stored in other elements at the old size. They can hold elements of any homogeneous type, including records and other arrays. You can declare a dynamic array the same as you declare … Read more

Redefine Class Methods or Class

It’s called monkey patching. But, PHP doesn’t have native support for it. Though, as others have also pointed out, the runkit library is available for adding support to the language and is the successor to classkit. And, though it seemed to have been abandoned by its creator (having stated that it wasn’t compatible with PHP … Read more

How to redefine a Ruby constant without warning?

The following module may do what you want. If not it may provide some pointers to your solution module RemovableConstants def def_if_not_defined(const, value) self.class.const_set(const, value) unless self.class.const_defined?(const) end def redef_without_warning(const, value) self.class.send(:remove_const, const) if self.class.const_defined?(const) self.class.const_set(const, value) end end And as an example of using it class A include RemovableConstants def initialize def_if_not_defined(“Foo”, “ABC”) def_if_not_defined(“Bar”, … Read more