Deepcopy: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: .perl -> .raku)
Line 1,848: Line 1,848:


<br>
<br>
'''2) Use <code>.perl.EVAL</code>:'''
'''2) Use <code>.raku.EVAL</code>:'''


<tt>.perl</tt> serializes the data structure to Raku code, and <tt>.EVAL</tt> deserializes it. Limitations:
<tt>.raku</tt> serializes the data structure to Raku code, and <tt>.EVAL</tt> deserializes it. Limitations:
* Doesn't work correctly if the data structure contains elements that can't be properly serialized, such as closures or file handles.
* Doesn't work correctly if the data structure contains elements that can't be properly serialized, such as closures or file handles.


<lang perl6>use MONKEY-SEE-NO-EVAL;
<lang perl6>my %x = foo => 0, bar => [0, 1];
my %y = %x.raku.EVAL;

my %x = foo => 0, bar => [0, 1];
my %y = %x.perl.EVAL;


%x<bar>[1]++;
%x<bar>[1]++;