bundler の path 指定 いつも最初に実行する度に忘れてググってしまう
$ bundle install --path vendor/bundler
class Numeric | |
def to_be_between(min, max) | |
self < min ? min : self > max ? max : self | |
end | |
end | |
p 4.to_be_between(5, 10) # => 5 | |
p 5.to_be_between(5, 10) # => 5 | |
p 8.to_be_between(5, 10) # => 8 | |
p 10.to_be_between(5, 10) # => 10 | |
p 11.to_be_between(5, 10) # => 10 |
// these are samples for async/await | |
async function rejecting() { | |
throw "reject!!!!"; | |
} | |
async function resolving(msg) { | |
await sleep(Math.random() * 10000); | |
return message = "resolve!" + (msg ? " -- " + msg : ""); | |
} | |
resolving() |
// JavaScript simple sleep function | |
// usage: await sleep(milliseconds) | |
function sleep(milliseconds) { | |
return new Promise(resolve => setTimeout(resolve, milliseconds)); | |
} |
// JavaScript Generator | |
function* getGenerator(index) { | |
while(index < 3) | |
{ | |
yield index++; | |
} | |
} | |
const generator = getGenerator(0); | |
console.log(generator); |
<?php | |
// ?? - null合体演算子(左辺がnull or 未定義の場合に右辺を返す) | |
// ?: - エルビス演算子(左辺がfalseとequalityな場合に右辺を返す) | |
unset($hoge); | |
$hoge = ($hoge ?? 1) ?: 2; | |
var_dump($hoge); | |
$hoge = NULL; | |
$hoge = ($hoge ?? 1) ?: 2; |
<?php | |
class A { | |
public static function classMethod() { | |
echo "class method\n"; | |
} | |
public function instanceMethod() { | |
echo "instance method\n"; | |
} |
<?php | |
class A | |
{ | |
protected function data(int $id) | |
{ | |
return "A"; | |
} | |
} | |
class B extends A |
<?php | |
/** | |
* 比較 self::hoge() and static::hoge() | |
*/ | |
class A1 { | |
public static function message() { | |
return "A1\n"; | |
} |
bundler の path 指定 いつも最初に実行する度に忘れてググってしまう
$ bundle install --path vendor/bundler