Created
May 24, 2019 16:58
-
-
Save dpavsrtrl/1987bdd8423dc8e609b30abf08da4c13 to your computer and use it in GitHub Desktop.
structural type equality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Ate | |
fun food(): String val => "Something" | |
interface Named | |
fun name(): String val => "Somebody" | |
type NamedEater is (Ate & Named) | |
class Charlie is (Ate & Named) | |
new create() => | |
None | |
fun name(): String val => "Charlie" | |
actor Main | |
var _env: Env | |
new create(env: Env) => | |
_env = env | |
var c = Charlie | |
use_named(c) | |
fun use_named(x : NamedEater) => | |
_env.out.print(x.name() + " ate " + x.food()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment