From 0a23d914f708a8790a0572f54bb616e5871afb47 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 26 Jan 2024 16:20:04 +1300 Subject: [PATCH] add defaultValue parameter to keyAs --- initial.d | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/initial.d b/initial.d index 7bfc03e..c85c999 100644 --- a/initial.d +++ b/initial.d @@ -229,16 +229,15 @@ struct INISection } /++ - + Using `std.conv`, converts the value of the given key - + to the given type. On conversion failure throws an - + `INITypeException` with a message containing location - + information. + + Using `std.conv`, converts the value of *k* to *T*. + + On conversion failure throws an `INITypeException` + + with a message containing location information. +/ T - keyAs(T)(string k) + keyAs(T)(string k, string defaultValue = null) { try - return key(k).to!T(); + return key(k, defaultValue).to!T(); catch (ConvException) throw new INITypeException( format!"unable to convert [%s].%s to %s"(name, k, T.stringof));