Slide 25
Slide 25 text
プログラムを修正する
修正箇所がわかったので早速直しましょう
25
function f(x, y) {
if (x <= y) {
return { x, y };
} else {
return { y, x };
}
}
function g(p) {
const x = p.x; // polymorphic
}
for (let i = 0; i < 1000; i++) g(f(0, 1));
g(f(1, 0));
polymorphicExample.js
function f(x, y) {
return { x, y };
}
function g(p) {
const x = p.x; // polymorphic
}
for (let i = 0; i < 1000; i++) g(f(0, 1));
g(f(1, 0));
polymorphicExample.js
※身も蓋も無い修正