19 lines
355 B
Python
19 lines
355 B
Python
from typing import Self
|
|
|
|
class Foo:
|
|
def __init__(self, x: int) -> None:
|
|
self.x = x
|
|
|
|
def combine(self: Self, other: Self) -> Self:
|
|
return Foo(self.x + other.x)
|
|
|
|
def __repr__(self: Self):
|
|
return f"Self {{ x: {self.x} }}"
|
|
|
|
def main():
|
|
f = Foo(3)
|
|
g = Foo(4)
|
|
h = f.combine(g)
|
|
print(f"{f=} {g=} {h=}")
|
|
|
|
main() |