blob: 15022411ca3e900f77c152429ddc20b3d694d30e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
class Frac {
constructor(num, den) {
this.num = num;
this.den = den;
}
[Symbol.toPrimitive]() {
return this.num / this.den;
}
display() {
const result = this.num / this.den;
process.stdout.write(`${result}`);
}
}
const f = new Frac(1, 2);
f.display();
|