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
<?php | |
// Assume this function definition: | |
function foo($bar, $baz = 'qux') { | |
return $bar.$baz; | |
} | |
// Oh crap, something went wrong, and we call it without arguments: | |
$foo = foo(); |
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
<?php | |
namespace traits; | |
trait Singleton { | |
// Для тех, кто не предусмотрел конструктор в классе | |
private function __construct() { | |
} |
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
def isPalindrome(word): | |
if len(word)<2: | |
return boolean(word) | |
return (word[0] is word[-1]) ? IsPalindrome(word[1:-2]) : False |
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
<?php | |
// accepts default string and test function. | |
// test function is tweaked everytime object of class LazyStrings is casted to string, | |
// if test function returns FALSE/NULL default string is returned, otherwise the result of | |
// test. | |
class LazyString { | |
private $_default, $_tweak; |
NewerOlder