diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-07-29 02:01:48 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-07-25 02:16:24 +0200 |
commit | f66b872bead5812e6da8579f893d835e17b7fdcf (patch) | |
tree | 1bb3b6f310ffc604afc24109f16ebeaadbc9d3a2 /lib | |
parent | 3b7d9c4638bc46913cb37a2f2046ee701f003c20 (diff) |
Add a fallback method in case the key for .get is Nil
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config.pm6 | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6 index 61cc3a1..f0a75c3 100644 --- a/lib/Config.pm6 +++ b/lib/Config.pm6 @@ -28,6 +28,13 @@ class Config is export return $!content; } + #| Fallback method in case the key is Nil. Will always return the default + #| value. + multi method get(Nil $key, Any $default = Nil) + { + $default; + } + #| Get a value from the config object. To get a nested #| key, use a . to descent a level. multi method get(Str $key, Any $default = Nil) |