Project

General

Profile

Actions

Bug #21538

open

initialize_dup not called when duping class/module

Added by chucke (Tiago Cardoso) 3 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:122945]

Description

Not sure whether this is expected behaviour or not, but just leaving it here to start the debate on whether callbacks like initialize_dup are supposed to be called when a module or class is duped (the same happens with initialize_copy and initialize_clone btw):

class A
  def initialize_dup(_)
    puts "dup instance"
    super
  end
  def self.initialize_dup(_)
    puts "dup class"
    super
  end
end

A.new.dup #=> "dup instance"
A.dup #=> nothing

No data to display

Actions

Also available in: Atom PDF

Like0