Why is MyClass.allocate a public method in Ruby? Under what circumstances would you want to create an object but not run initialize on it?
Deserialization comes to mind. A class may be serializable but might not have an initialize that takes no arguments, and that code shouldn't need to initialize it to something just to immediately undo that work.
Basically any scenario where you initialize an object differently then your typical case it becomes useful to separate those two steps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With