/// <summary> /// Parse the string into a number /// </summary> /// <param name="defaultIfError">If the string parse fails, return this value instead. Note that if /// this optional value is left off, a KOSexception will be thrown on parsing errors instead.</param> /// <returns></returns> public ScalarValue ToScalar(ScalarValue defaultIfError = null) { ScalarValue result; if (ScalarValue.TryParse(internalString, out result)) { return(result); } else if (defaultIfError != null) { return(defaultIfError); } throw new KOSNumberParseException(internalString); }