Created
May 1, 2014 09:57
-
-
Save rogierslag/37db78843ceccb523d9a to your computer and use it in GitHub Desktop.
Hack type safety
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
<?hh //strict | |
function newline() : void { | |
echo "\n"; | |
} | |
function number() : int { | |
return 123; | |
} | |
function string() : string { | |
return "123test"; | |
} | |
function main() : void { | |
var_dump(number() == string()); //true | |
var_dump(number() === string()); //false | |
newline(); | |
var_dump(string() == number()); //true | |
var_dump(string() === number()); //false | |
newline(); | |
var_dump(string() == A::JUST_A_NICE_CONSTANT); //true | |
var_dump(string() === A::JUST_A_NICE_CONSTANT); //false | |
} | |
class A { const int JUST_A_NICE_CONSTANT = 123; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment