I recently saw some code like this code:
val x: Any = "a"
val y = x.## // y: Int = 97
Well, ok the output is just the ASCI value of 'a', but lets have a look at
List(1,2).## // Int = 985731359
List(1,2).toString.## // Int = 1063384434
My IDE tells about '##' that it is a 'Synthetic Function'. So what is ## doing and what is a Synthetic Function?
Normal blood test results for typical liver function tests include: ALT. 7 to 55 units per liter (U/L) AST. 8 to 48 U/L. ALP. 40 to 129 U/L.
If you have high levels of AST and/or ALT, it may mean that you have some type of liver damage. You may also have an AST test as part of a group of liver function tests that measure ALT, and other enzymes, proteins, and substances in the liver.
What ALT level is considered high? The upper limit of normal for ALT is 55 IU/L. When an ALT level is double to triple the upper limit of normal, it is considered mildly elevated. Severely elevated ALT levels found in liver disease are often 50 times the upper limit of normal.
The common tests that assess liver synthetic function are albumin and prothrombin time or INR.
Synthetic function. The tests of synthetic function in the liver include prothrombin time (PT)/international normalized ratio (INR), platelet count and albumin level. Abnormal results indicate disease that has caused loss of proteins or inability to synthesize proteins.
It's basically an alias of hashCode
, with a couple of notable exceptions that make it somewhat safer:
Equivalent to
x.hashCode
except for boxed numeric types andnull
. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. Fornull
returns a hashcode wherenull.hashCode
throws aNullPointerException
.
(source: https://www.scala-lang.org/api/current/scala/Any.html###:Int)
Examples:
normal value
scala> val x: Any = "a"
x: Any = a
scala> x.hashCode
res2: Int = 97
scala> x.##
res3: Int = 97
null value
scala> null.hashCode
java.lang.NullPointerException
... 33 elided
scala> null.##
res5: Int = 0
A synthetic field, instead, is a field generated by the compiler to work around the underlying JVM limitations, especially when dealing with inner anonymous classes, a concept extraneous to the JVM.
Here's a good explanation of what it means in details: http://javapapers.com/core-java/java-synthetic-class-method-field/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With