Skip to content

Instantly share code, notes, and snippets.

@dana-ross
Created January 30, 2016 17:04
Show Gist options
  • Save dana-ross/429887f4d5de74a36c25 to your computer and use it in GitHub Desktop.
Save dana-ross/429887f4d5de74a36c25 to your computer and use it in GitHub Desktop.
<?php
use DaveRoss\FunctionalProgrammingUtils\Just as Just;
$f = function( $value ) {
$retval = $value + 2;
$value = 5; // Who cares?
return $retval;
};
$g = function( $value ) {
return $value + 3;
};
$myObj = Just::of(1);
echo $myObj->map( $f )->value() + $myObj->map( $g )->value(); // Outputs 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment