示例#1
0
 /**
  * This method tests the "covariant" method.
  */
 public function test_covariant()
 {
     $p0 = IOption\Type::covariant(IOption\Type::some(IInt32\Type::zero()));
     $this->assertInstanceOf('\\Saber\\Data\\IOption\\Type', $p0);
     $p1 = IOption\Type::covariant(IOption\Type::none());
     $this->assertInstanceOf('\\Saber\\Data\\IOption\\Type', $p1);
 }
示例#2
0
 /**
  * This method (aka "flatMap") binds the subroutine to the object within this option.
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param callable $subroutine                              the subroutine function to be applied
  * @return IOption\Type                                     the option
  */
 public static function bind(IOption\Type $xs, callable $subroutine) : IOption\Type
 {
     return $xs->__isDefined() ? IOption\Type::covariant($subroutine($xs->item(), IInt32\Type::zero())) : IOption\Type::none();
 }