Created
December 27, 2014 07:12
-
-
Save ostretsov/31964fd8b5f7ba808383 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
package ostretsov | |
import scala.collection.mutable | |
/** | |
* Created by rufog on 27.12.14. | |
*/ | |
object Client { | |
var lastId = 0; | |
val cache = new mutable.HashMap[String, Client]() | |
def build(name: String, isScalaGuy: Boolean) = { | |
if (!cache.contains(name)) { | |
lastId += 1 | |
val newClient = new Client | |
newClient.id = lastId | |
newClient.name = name | |
newClient.isScalaGuy = isScalaGuy | |
cache += (newClient.name -> newClient) | |
newClient | |
} else | |
cache(name) | |
} | |
} | |
class Client { | |
var id = 0 | |
var name = "No name" | |
var isScalaGuy = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment