diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-04-26 08:09:05 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-07-25 02:16:12 +0200 |
commit | 761b255cff8ad709c7292029417337d74eda9d87 (patch) | |
tree | dd8442d67efa5214d0bda3280ecc0c012a5a8a83 /lib | |
parent | 1cacfc74a1c53fd000d608128e393a968b01bb39 (diff) |
Add a multi method set() that accepts an array for the key
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config.pm6 | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6 index 2369b6f..1d0d7db 100644 --- a/lib/Config.pm6 +++ b/lib/Config.pm6 @@ -160,11 +160,16 @@ class Config is export } #| Set a single key to a given value; - method set(Str $key, Any $value) + multi method set(Str $key, Any $value) + { + self.set($key.split("."), $value); + } + + multi method set(Array $keyparts, Any $value) { my $index := $!content; - for $key.split(".") -> $part { + for $keyparts -> $part { $index{$part} = {} unless defined($index{$part}); $index := $index{$part}; |