time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (650B)


      1 
      2 {{alias}}( x, y )
      3     If a function does not throw, returns the function return value; otherwise,
      4     returns `y`.
      5 
      6     Parameters
      7     ----------
      8     x: Function
      9         Function to try invoking.
     10 
     11     y: any
     12         Value to return if a function throws an error.
     13 
     14     Returns
     15     -------
     16     z: any
     17         Either the return value of `x` or the provided argument `y`.
     18 
     19     Examples
     20     --------
     21     > function x() {
     22     ...     if ( {{alias:@stdlib/random/base/randu}}() < 0.5 ) {
     23     ...         throw new Error( 'beep' );
     24     ...     }
     25     ...     return 1.0;
     26     ... };
     27     > var z = {{alias}}( x, -1.0 )
     28     <number>
     29 
     30     See Also
     31     --------
     32