From 000a217ccd93edd79a67bbe0023d4c695a016cc7 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sat, 29 Jul 2017 02:01:48 +0200 Subject: Add a fallback method in case the key for .get is Nil --- lib/Config.pm6 | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') 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) -- cgit v1.1