I seem to recall seeing somewhere a clone() method for Moose objects. I've looked in Moose and Moose::Manual::Construction but don't see anything like this. I've also had a poke around in Super Search but have found nothing promising.
In my current code, I writing this type of thing:
my $cloned_object = ref($existing_object)->new();
This works fine for what I'm working on at the moment because the classes in question have no required attributes and taking the defaults is exactly what I want in this instance.
I don't have any requirement to do anything different at the moment; however, it occurs to me that I might do in the future, perhaps something like:
my $cloned_object = ref($object)->new(%objects_attrs_and_values);
which might be better as something like:
my $cloned_object = $existing_object->clone();
So, is there such a thing as clone() or did I just imagine it? If it exists, please point me to documentation; if not, any related thoughts on this are welcome.
— Ken
In reply to Moose 'clone' Constructor by kcott
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |