> To go the other way (string to int) is a proc called parseInt(). To make it a 
> bit more robust:

using varargs here works, but isn't optimal. A default param value is not only 
more clear regarding the intention, but it also doesn't allow for passing more 
than one extra parameter in.
    
    
    proc str2int*(s: string, d = 0): int =
      result = try: parseInt(s) except ValueError: d
    
    
    Run

Reply via email to