-
-
Save szeiger/180900 to your computer and use it in GitHub Desktop.
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
object DSL2 { | |
def main(args: Array[String]): Unit = { | |
val m1 = Machine(Agent("agent1"), null) | |
val m2 = Machine(Agent("agent2"), m1) | |
val m3 = Machine(Agent("agent3"), m2) | |
val selector = agent.compose(parent.compose(parent)) | |
println("Name of agent: " + selector(m3).name) | |
println("Name of agent of m3: " + agent(m3).name) | |
} | |
val agent = (_:Machine).agent | |
val parent = (_:Machine).parent | |
} | |
sealed case class Agent(name: String) | |
sealed case class Machine(agent: Agent, parent: Machine) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment