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
package main | |
import "fmt" | |
type FlyBehavior interface { | |
Fly() | |
} | |
type FlyWithWings struct{} |
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
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
func TestStrategyPattern(t *testing.T) { | |
ducks := []Duck{ | |
NewMallardDuck(), |
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
package main | |
import "fmt" | |
type QuackBehavior interface { | |
Quack() | |
} | |
type Quack struct{} |
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
package main | |
import "fmt" | |
type Duck interface { | |
PerformFly() | |
PerformQuack() | |
Swim() | |
Display() | |
} |
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
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))) { |
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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
// とりあえず初期化 | |
var dam WaterIntake = &Dam{Store: []string{"水", "水", "水"}} | |
var filtrationPlant Filtration = &FiltrationPlant{} |
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 App\Policies; | |
use App\User; | |
use App\Post; | |
use Illuminate\Auth\Access\HandlesAuthorization; | |
class PostPolicy | |
{ |
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
class HelloComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
// handlerを使用する場合、ここでbindする | |
} | |
//ES6 Classのメソッド記法はfunctionが必要ない | |
render() { | |
return ( | |
<div className="hello"> |
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
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"strings" | |
) | |
func main() { |
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 fib(n): | |
print(n, end=' ') # 計算を可視化するためのprint | |
if n < 2: | |
return n | |
return fib(n - 1) + fib(n - 2) |