So, I just found out about scala class classes, and they tell me that they are used to provide a simple wrapper around a lot of properties, to make it easier to check for equality. But now I have two questions:
Firstly, a structin C ++ and structin C # are two different things. So the assignment of case classes in scala coincides with those that 2 things do not make sense.
struct
++ - , . . .
# . , . Java. ++, class struct.
class
, , # ( ), Java/# ( ). . , .
, - JVM. , , . - , case , #. JVM , GC ( ).
, :
.
. scala case ... scala.
scala , , .copy .apply .unapply -. .toString , .equals, , ref.
.copy
.apply
.unapply
.toString
.equals
scala.
Scala Java. .
Scala case scala, :
public final
var
equals
hashCode
apply
unapply
toString
copy
Here is an example:
case class MasterOfTheUniverse(name: String, power: Int) scala> MasterOfTheUniverse("He-Man", 100).name res1: String = He-Man scala> MasterOfTheUniverse("He-Man", 100).power res2: Int = 100 scala> MasterOfTheUniverse("He-Man", 100).toString res3: String = MasterOfTheUniverse(He-Man,100) scala> MasterOfTheUniverse("He-Man", 100) == MasterOfTheUniverse("She-Ra", 90) res4: Boolean = false scala> MasterOfTheUniverse("She-Ra", 90) == MasterOfTheUniverse("She-Ra", 90) res6: Boolean = true scala> MasterOfTheUniverse("He-Man", 100).copy(name = "He-Manatee") res7: MasterOfTheUniverse = MasterOfTheUniverse(He-Manatee,100)
Source: https://habr.com/ru/post/1679526/More articles:How to unsubscribe from redux store when the component disconnects? How to decorate redux connection? - javascriptJSON gets the url of the data form using javascript and saves the data in var - jsonStatistics of several identically named columns - rПоворот индексов на шестиугольник - javascriptReact Native Redux - initialize default state from asyncstorage - react-nativeGitHub pages: 404 on / but / index.html works fine - markdown"Error: SignerSign () failed." (-2147023673 / 0x800704c7) - windowsWF 4.0 Long Term Processing Using TPL - c #How to write a lengthy job to call web services in WF 4.0 - c #Plots.jl - Turn off axes and grid lines - julia-langAll Articles