Why does class # allocate a public method in Ruby?

Why MyClass.allocatean open method in Ruby? Under what circumstances do you want to create an object but not run initializeon it?

+3
source share
2 answers

Deserialization begins. A class may be serializable, but may not have an initialization that takes no arguments, and this code should not initialize it with something to immediately cancel this work.

Basically, any scenario in which you initialize the object in a different way, and then your typical case, it is useful to separate these two steps.

+4
source

"" , - (: Time.allocate "", )

0

Source: https://habr.com/ru/post/1793377/


All Articles