case class Player(@volatile var hand: Hand,
var deck: Deck,
var discards: Discards,
var actions: Int,
var score: Int,
var money: Int) {
}
I asked this question in scala-language, but maybe this is a better forum for asking it:
Home > My AccountParticipant Statement: CivilianPrint this pageText size:Quarterly StatementsAnnual StatementsYou can view or download your past or current quarterly participant statements. As quarterly statement information becomes available (generally around mid-month in January, April, July, and at
val player = Player( ... )
val result = GameLibrary.calculateSomethingAboutPlayer(player)
// has player changed???
val player = Player( ... ) // Here, Player is a case class without vars
val richPlayer = player.copy(money = 1000000)
case class Player(@volatile var hand: Hand,
@volatile var deck: Deck,
@volatile var discards: Discards,
@volatile var actions: Int,
@volatile var score: Int,
@volatile var money: Int) {
}
Then this will be thread safe. To encapsulate better I intend to make these variables private and add some logic methods to the Player object. What could be improved with this design as compared to what you are suggestign?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/13/2015 01:20 PM, Richard Bradley wrote:
> The specific problem with your proposal here is that the contract
> of a Case Class is that it is immutable.
A serious question: where is this spelled out? My understanding is
that case classes just cause the compiler to generate some
boilerplate; the 'case' modifier doesn't imply anything about member
access or mutability.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBAgAGBQJWHUBhAAoJEBnktRkJHUgscUUP/07jbaWqpjzrMICZYggJtSjT
RR4ZMejcO7ZooCdM6Pbhxttr7a6qLqvtSgabK9yqh0WCjfaafMvfGtUmhIL7yPrE
FEZK/7a9uT6xVmlL6mHlDDT4mrf0eejduMfl5B28xN6gC3A7Kx5TRw4azuk4r6+D
TU6bsQjbCRBBep5XLZWoJAFiU+/CuOwvY5gZasng2Nz0y3ohAFf323JxMMTpL/st
agy4YMgC9664M8uI8q9aLCE5j1I2aPyOTZcnIFWiEWp+YONeh42DM96+QdnqZwKq
cxL18wLxv2GrhJaVBmLG99eaG0opbAdKvYB0MrJeBqY0i/ji+H8cgTCX7d76c++x
luYGsl1SYeyuXP2SRHTFXClQqF1vyl8yNitX8YycXc0OndMV9HfarwEqCM2Yc3En
ZUQqxceHpGLT6yfs6bAMLgfLAdxysmlbOozxjicrbqrapuIESHRjBcPsWlopdj87
Q+Wqvw212gOsKf+Sb7nnNSu+eWLpjraRfngQWrXXIepkRPXMy0IdqmEPOjXNWe9r
M4TRA7qBLBj2qGetxNeRmj1RC+ooAm6eA4gtBObVFbLzypUq7wyG38PKqRQOefat
j/ehWAPLH36PALa7HzL/3z8J/JZ/vIscAKi99PHC99oBqtXdN7uT3Vw0nLqPgc1i
avTvWrxzakSidSEEWdJY
=3TPA
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
equals
comparisons on the object is modified> <mailto:scala-user+unsub...@googlegroups.com>. For more options,