Skip to content

Instantly share code, notes, and snippets.

@ostretsov
Created December 27, 2014 07:12
Show Gist options
  • Save ostretsov/31964fd8b5f7ba808383 to your computer and use it in GitHub Desktop.
Save ostretsov/31964fd8b5f7ba808383 to your computer and use it in GitHub Desktop.
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