Yes, BigDecimal implements a new class method, and if you override it in your test2 class, you can write your Test2 initialization method in any way, for example,
class Test2 < BigDecimal def self.new(a) puts a end def initialize(a) puts a end end Test2.new("a")
The class method new is the constructor of the object, which sets the state of the object and allocates memory after the object is initialized using the initialize method.
But usually we donβt implement the new method, since it is the standard constructor method provided by ruby, although you can override it by overriding it in your class if there is a good reason for this, and this is what BigDecimal did.
source share