diff --git a/initial.d b/initial.d index 1181b9f..289c33c 100644 --- a/initial.d +++ b/initial.d @@ -234,10 +234,10 @@ struct INISection + with a message containing location information. +/ T - keyAs(T)(string k, string defaultValue = null) + keyAs(T)(string k, T defaultValue) { try - return key(k, defaultValue).to!T(); + return k in keys ? keys[k].to!T() : defaultValue; catch (ConvException) throw new INITypeException( format!"unable to convert [%s].%s to %s"(name, k, T.stringof));