On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote:
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
---------------------------------------------------------
try this:
https://dlang.org/phobos/std_exception.html#ifThrown



Worked. Thanks.

import std.stdio;
import std.conv: to;
import std.exception: ifThrown;

void main( string[] args ){
        
        string str = "string";
int index = to!int( str ).ifThrown( 0 ); // if an exception was thrown, it is ignored and then return ( 0 );
        writeln( "index: ", index );  // 0
}


Reply via email to