Solución
solution.tsTypeScript
from typing import Protocol
# Define el Protocol Displayable con el metodo label() -> str
# Implementa una clase que lo satisfaga
class Displayable(Protocol):
def label()-> str: ...
class ObjectForDisplay():
def __init__(self, label):
self.label = label
def label()-> str:
return self.label
def display_all(items: list[dict]) -> list[str]:
# Crea objetos Displayable y retorna la lista de strings de label()
label_list = []
for item in items:
obj = ObjectForDisplay(item.get("label"))
label_list.append(obj.label)
return label_list0respuestas