Created
July 10, 2020 16:24
-
-
Save Crell/1e8decec66e2200a6a91eb69e9d7f831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Option { | |
case None = new class {}; | |
case Some = new class($val) { | |
public function __construct(private $val) {} | |
public function value() { return $val; } | |
}; | |
public function value{} { throw new TypeError; } | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Option { | |
case None; | |
case Some = new Some($val); | |
public function value{} { throw new TypeError; } | |
} | |
class Some extends Option { | |
public function __construct(private $val) {} | |
public function value() { return $val; } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment