Skip to content

Instantly share code, notes, and snippets.

package main
import "fmt"
type FlyBehavior interface {
Fly()
}
type FlyWithWings struct{}
package main
import (
"fmt"
"testing"
)
func TestStrategyPattern(t *testing.T) {
ducks := []Duck{
NewMallardDuck(),
package main
import "fmt"
type QuackBehavior interface {
Quack()
}
type Quack struct{}
package main
import "fmt"
type Duck interface {
PerformFly()
PerformQuack()
Swim()
Display()
}
let twice = fn(f, x) {
return f(f(x));
};
let addTwo = fn(x) {
return x + 2;
};
twice(addTwo, 2);
let unless = macro(condition, consequence, alternative) {
quote(if (!(unquote(condition))) {
package main
import (
"fmt"
)
func main() {
// とりあえず初期化
var dam WaterIntake = &Dam{Store: []string{"水", "水", "水"}}
var filtrationPlant Filtration = &FiltrationPlant{}
<?php
namespace App\Policies;
use App\User;
use App\Post;
use Illuminate\Auth\Access\HandlesAuthorization;
class PostPolicy
{
class HelloComponent extends React.Component {
constructor(props) {
super(props);
// handlerを使用する場合、ここでbindする
}
//ES6 Classのメソッド記法はfunctionが必要ない
render() {
return (
<div className="hello">
package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
func main() {
@NAKKA-K
NAKKA-K / file0.py
Last active April 24, 2019 08:40
pythonで説明するキャッシュの凄さ ref: https://qiita.com/NAKKA-K/items/da7133f0b80657318692
def fib(n):
print(n, end=' ') # 計算を可視化するためのprint
if n < 2:
return n
return fib(n - 1) + fib(n - 2)