I understand that one of the main advantages of using an object is that they are real objects, and not the functionality of the system. But finally, these objects are also available in the system.
In addition to being more “clean,” this offers the added benefit of scala “objects.”
I am sure there is a number, but I can not figure out which one.
.
object X { private[this] val z=1 } class X { import X._ //won't compile println(z) }
, , - , . Java , .
Java:
class StaticJava { static String AA = "Static String"; StaticJava() { } }
StaticJava, AA , .
Scala:
object StaticScala { val AA = "Static String" } class StaticScala
StaticScala StaticScala $, StaticScala singleton.
, . , , .
: ( ).
, , .
, , , , , , , orrible getInstance(). .
, concurrency.
, . - , . , ( , ).
, .
, Java . Scala .
Source: https://habr.com/ru/post/1781289/More articles:Import data into SQL Server 2008 Express - c #Does the catch attempt really affect performance? - .netRuby libs для Twitter-потоков пользователей/сайтов? - rubyiPhone Icons retina / normal with Ending: @ 2x.png - iphoneИспользование Oracle.DataAccess.DLL уже на ПК, не предоставляя его - c#Drawing unicode strings with CoreGraphics - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1781291/how-to-manage-multiple-calls-to-membershipgetuser-efficiently&usg=ALkJrhgMENLRtW0xg0bZ5RxvF52kJqSBaAMoving MSTEST classes to their own folders breaks "Create unit tests ..." - unit-testingDownload XML or XHTML using encoded or shielded html characters - c #WebException Failed to establish trust for SSL / TLS secure channel - c #All Articles