type Crate{health} {
health: float
}
type Enemy{health} {
health: float
}
spec Damageable {
health: float
hit(mut self, float damage) -> none {
self.health -= damage
}
}
Crate crate = new { health = 30 }
Enemy enemy = new { health = 50 }
span<Damageable> crateAsDamageable = crate<Damageable>
crateAsDamageable.hit(10)
span<Damageable> enemyAsDamageable = enemy<Damageable>
enemyAsDamageable.hit(5)
че думаете