Got an idea of a new assignment operator ?= in PHP.
Instead of writing
if (!$x)
$x = $y;one could use ?= and write
$x ?= $y;Got an idea of a new assignment operator ?= in PHP.
Instead of writing
if (!$x)
$x = $y;one could use ?= and write
$x ?= $y;| class Rectangle | |
| { | |
| protected double width, height; | |
| constructor(double width, double height) | |
| { | |
| this.width = width; | |
| this.height = height; | |
| } |
| <?php | |
| class Base | |
| { | |
| private $x; | |
| public function getX() | |
| { | |
| return $this->x; | |
| } |
| <?php | |
| $tweet = 'Detta är ett #test för min blog... #ignoreme #lördag #måla #mäktigt #coolt #åsa-nisse #()lol()'; | |
| $pattern = '/#(\pL+)/'; | |
| $replacement = '<a href="#$1">$0</a>'; | |
| echo preg_replace($pattern, $replacement, $tweet); |
| var M = function() { }; | |
| M.prototype = { | |
| m : function() { return 42 } | |
| }; | |
| var inst = new M(); | |
| inst.f = function() { return 42 }; |
| // Recursive version | |
| function isMeasurable(target, weights) | |
| { | |
| if (weights.length == 0) | |
| return target == 0; | |
| var first = weights.shift(); | |
| return | |
| isMeasurable(target-first, weights) || |
| Att stödja en regeringen är inte samma sak som att sitta i regeringen. Flyborg påstod att MP var "i regeringsställning", vilket betyder att man verkligen sitter i regeringen. |
| data Tree t = EmptyTree | |
| | Node t (Tree t) (Tree t) | |
| deriving Show | |
| nivel :: Int -> Int | |
| nivel n = nivel' n 0 | |
| where | |
| nivel' 0 _ = 0 | |
| nivel' 1 x = x | |
| nivel' n x = nivel' (n `div` 2) (x + 1) |
| firstNonRep :: String -> Maybe Char | |
| firstNonRep cs = fmap fst $ find (\(c, n) -> n == 1) $ foldl count [] cs | |
| where | |
| count [] c = [(c, 1)] | |
| count (p@(c', n) : ps) c | c == c' = (c', n+1) : ps | |
| | otherwise = p : count ps c |