Interfaces
Declare and implement an interface so unrelated classes share a contract.
interfaces in ~90 seconds.Deep in the jungle, the Code Pyramid waits for an ancient relic to glow green, but the ruin's magic doesn't care which specific relic it is, as long as it knows how to activate.
An interface is a strict contract that forces unrelated classes to share the exact same methods, like our activatable rule that demands an Activate function.
We define the interface at the top, then our jungle_relic class signs the contract by overriding that method, letting our main pyramid device call it cleanly.
Reach for interfaces when you want completely different game objects to share a common action without forcing them into the same rigid family tree.
activatable := interface():
Activate() : void
jungle_relic := class(activatable):
Activate<override>() : void = Print("Glow")
pyramid_demo := class(creative_device):
Relic : jungle_relic = jungle_relic{}
OnBegin<override>()<suspends>:void =
Relic.Activate()
Build your own lesson with interfaces
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →