You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know it is possible to provide default values when prompting the user for input. See below:
letlevel=ask("Choose level: ", type:Int.self){ settings in
settings.defaultValue =1}
Unfortunately this value is only used in preparedItem() which is not called anywhere. When the user does not provide an input he gets the message to enter a valid integer despite the fact I chose a default value.
publicclassAskSettings<T:ArgConvertibleType>{
/// Default value to set incase the user entered a blank
publicvardefaultValue:T?...func preparedItem(originalString string:String)->T{
if string.isEmpty && defaultValue !=nil{return defaultValue!
}returnT.fromString(string)!
}}
The text was updated successfully, but these errors were encountered:
I know it is possible to provide default values when prompting the user for input. See below:
Unfortunately this value is only used in
preparedItem()
which is not called anywhere. When the user does not provide an input he gets the message to enter a valid integer despite the fact I chose a default value.The text was updated successfully, but these errors were encountered: