From 35e9b52620d540f79baac2c93caa19f4b8258679 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sun, 15 Nov 2020 08:41:11 +0100 Subject: Update usage documentation --- README.rakudoc | 83 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/README.rakudoc b/README.rakudoc index 9758b69..ea8b5f4 100644 --- a/README.rakudoc +++ b/README.rakudoc @@ -1,7 +1,7 @@ =begin pod -=NAME Log -=VERSION 1.0.0 +=NAME Hash::Merge +=VERSION 2.0.0 =AUTHOR Patrick Spek =head1 Description @@ -10,26 +10,65 @@ A module for the Raku programming language to easily deep-merge two hashes. =head2 Usage - my %alpha = - a => 'b', - c => { - d => 'e', - f => 'g', - }, - ; - - my %beta = - z => 'y', - c => { - x => 'w', - }, - ; - - my %merged = merge-hash(%alpha, %beta); - -=head2 Documentation - -There's currently no extensive documentation available. +Base usage requires you to C the module, and pass two Ces to the +imported function, C. + +=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: + +=defn C +When set to C, this will not deep merge the Ces. This means that +the second C that is passed, will I C elements in the +first C, instead of combining them. + +=defn C +When set to C, this will not append C elements. This means +that any C elements in the second C will I +C elements in the first C. + +There is also a C in this module that allows you to call C<.merge> on +existing C objects. This requires C. 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 -- cgit v1.1