1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
=begin pod
=NAME Hash::Merge
=VERSION 2.0.0
=AUTHOR Patrick Spek <p.spek+raku@tyil.nl>
=head1 Description
A module for the Raku programming language to easily deep-merge two hashes.
=head2 Usage
Base usage requires you to C<use> the module, and pass two C<Hash>es to the
imported function, C<merge-hash>.
=begin code
use Hash::Merge;
my %alpha =
a => 'b',
c => {
d => 'e',
f => 'g',
},
;
my %beta =
z => 'y',
c => {
x => 'w',
},
;
my %merged = merge-hash(%alpha, %beta);
=end code
There are two potential options to pass to C<merge-hash>:
=defn C<Bool:D :$deep = True>
When set to C<False>, this will not deep merge the C<Hash>es. This means that
the second C<Hash> that is passed, will I<overwrite> C<Hash> elements in the
first C<Hash>, instead of combining them.
=defn C<Bool:D :$positional-append = True>
When set to C<False>, this will not append C<Positional> elements. This means
that any C<Positional> elements in the second C<Hash> will I<overwrite>
C<Positional> elements in the first C<Hash>.
There is also a C<use> in this module that allows you to call C<.merge> on
existing C<Hash> objects. This requires C<Hash::Merge::Augment>. While this is
a fancy way to work, it will break pre-compilation of whatever module is using
it.
=begin code
use Hash::Merge::Augment
my %alpha =
a => 'b',
c => {
d => 'e',
f => 'g',
},
;
%alpha.merge({
z => 'y',
c => {
x => 'w',
},
});
=end code
=head2 Contributing
The module's source code is available at the following locations:
=item L<https://gitlab.com/tyil/raku-hash-merge>
=item L<https://github.com/scriptkitties/p6-Hash-Merge>
If you have a change you would like to include, please send a patch to
L<mailto:~tyil/raku-devel@lists.sr.ht>.
=head2 License
This module is distributed under the terms of the Artistic License 2.0. For
more information, consult the LICENSE file in the module's source code
repository.
=end pod
|