Created
August 3, 2013 05:06
-
-
Save lu911/6145257 to your computer and use it in GitHub Desktop.
Inner class
This file contains 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
import scala.collection.mutable.ArrayBuffer | |
object Main { | |
def main(args: Array[String]): Unit = { | |
val n1 = new Network | |
val n2 = new Network | |
val loup = n1.join("loup") | |
val bob = n2.join("bob") | |
} | |
class Network() | |
{ | |
class Member(val name: String) | |
{ | |
val contacts = new ArrayBuffer[Member] | |
} | |
var members = new ArrayBuffer[Member] | |
def join(name: String) = { | |
val m = new Member(name) | |
members += m | |
m | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment