Created
September 28, 2008 10:08
-
-
Save bjartek/13440 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 Person { | |
def apply(firstName: String, lastName: String, age:int): Person = new Person(firstName, lastName, age) | |
def apply(name: String, age:int): Person = { | |
val parts = name.split(" ").toList | |
new Person(parts(0), parts.tail.mkString(" "), age) | |
} | |
} | |
class Person(var firstName: String, var lastName: String, var age: int) { | |
def name = firstName + " " + lastName | |
def name_= (name:String) { | |
val parts = name.split(" ").toList | |
firstName = parts(0) | |
lastName = parts.tail.mkString(" ") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment