3 ms·
It’s trivial to do with nominal type. In Python: ```Hash = NewType('Hash', str) def generate_hash(what: str) -> Hash: return Hash(f“hashed_{what}”)```
by rednafi 2y ago
It’s trivial to do with nominal type.
In Python:
```Hash = NewType('Hash', str)
def generate_hash(what: str) -> Hash:
return Hash(f“hashed_{what}”)```
- hombre_fatal 2y agoWhat makes it trivial here isn't nominal vs structural typing but rather that Python has a utility function for this case while you have to implement it yourself in Typescript with a one-liner.