diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-07-29 02:01:48 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-07-29 02:01:48 +0200 |
commit | 000a217ccd93edd79a67bbe0023d4c695a016cc7 (patch) | |
tree | 1bb3b6f310ffc604afc24109f16ebeaadbc9d3a2 /lib/Config.pm6 | |
parent | 1b638f16bd34f757fe2e1bcaf0cfa4a2f75c79f7 (diff) |
Add a fallback method in case the key for .get is Nil
Diffstat (limited to 'lib/Config.pm6')
-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) |