Lua – Number to string behaviour

In Lua 5.2 or earlier, both tostring(10) and tostring(10.0) result as the string “10”. In Lua 5.3, this has changed: That’s because Lua 5.3 introduced the integer subtype. From Changes in the Language: The conversion of a float to a string now adds a .0 suffix to the result if it looks like an integer. (For instance, the float 2.0 will be printed as 2.0, not … Read more

How do I print my Java object without getting “SomeType@2f92e0f4”?

Background All Java objects have a toString() method, which is invoked when you try to print the object. This method is defined in the Object class (the superclass of all Java objects). The Object.toString() method returns a fairly ugly looking string, composed of the name of the class, an @ symbol and the hashcode of the object in hexadecimal. The code for this looks like: … Read more