Changes for page WebObjects with Scala

Last modified by Ravi Mendis on 2011/05/10 02:10

From version 478.1
edited by Ravi Mendis
on 2010/12/23 23:53
Change comment: There is no comment for this version
To version 481.1
edited by Ravi Mendis
on 2010/12/23 23:58
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -44,9 +44,10 @@
44 44  
45 45  === Thread-Safe Shared Vars ===
46 46  
47 -Scala doesn't have static variables or methods. Instead Scala employs the [[Singleton Pattern>>http://en.wikipedia.org/wiki/Singleton_pattern]] which is built into the language and is **thread-safe**: a class can have a //Companion Object// that will allow you to achieve something equivalent to static variables - but better. This is not however true for mutable ##val## e.g: ##NSMutableArray##, ##scala.collection.mutable.ListBuffer##
47 +Scala doesn't have static variables or methods. Instead Scala employs the [[Singleton Pattern>>http://en.wikipedia.org/wiki/Singleton_pattern]] which is built into the language and is **thread-safe**: a class can have a //Companion Object// that will allow you to achieve something equivalent to static variables - but better.
48 48  
49 -So you don't have to worry about synchronizing access to shared mutable fields in a concurrent application.
49 +You don't have to worry about synchronizing access to shared mutable fields in a concurrent application.
50 +This is not however true for mutable ##val## e.g: ##NSMutableArray##, ##scala.collection.mutable.ListBuffer## which you will have to synchronize the adding to or removing from.
50 50  
51 51  The following is an example of the use of a //Companion Object// for Talent in Scala instead of Talent static fields in Java.
52 52