It seems like these all are exclusive to dynamically/weakly typed languages. Anyone have examples of wats for languages with strong static typing?
[0]: http://www.javapuzzlers.com/
[1]: https://www.youtube.com/watch?v=wbp-3BJWsU8
* Reassigning interned integers via reflection
* private fields work on a class level, not an instance level, i.e. Instances of a class can read private fields of other instances of the same class.
* Arguably package-private fields as the docs like to avoid mentioning they exist.
* ==, particularly in regards to boxed types.
* List<String> x = new ArrayList<String>() {{ add("hello"); add("world"); }};
* The behaviour of .equals with the object you create above
* Type Erasure
System.out.println(0.0 == -0.0); // true
System.out.println(java.util.Arrays.equals(new double[] {0.0}, new double[] {-0.0})); // false
(It's documented in the contract for Arrays.equals, but still kind of ridiculous.) # let x = ref 0;;
val x : int ref = {contents = 0}
# let y = ref 0;;
val y : int ref = {contents = 0}
# if false then
x := 1;
y := 1;
;;
- : unit = ()
# (!x, !y);;
- : int * int = (0, 1)
# y := 0;;
- : unit = ()
# if false then
let z = 1 in
x := z;
y := z;
;;
- : unit = ()
# (!x, !y);;
- : int * int = (0, 0)Oh, and `null`, in any language ;-)