Dollar dollar= (Dollar) object;
What does this snippet in do? Is it even Java? Or Smalltalk? I found it in TDD, which i think was written with Smalltalk in mind.
Dollar dollar= (Dollar) object;
What does this snippet in do? Is it even Java? Or Smalltalk? I found it in TDD, which i think was written with Smalltalk in mind.
This could be Java. It basically casts an object of generic type (perhaps just Object) to a Dollar object.
Example:
Object object = ObjectFactory.getObject(); // Gets object
Dollar dollar = (Dollar) object; // Cast to Dollar object, will throw an exception
// if this isn't possible
dollar.dollarMethod(); // I can now call Dollar methods
It creates a new variable of class Dollar, with the name dollar. Then it assigns a value to that variable by casting to Dollar a variable named object. It's valid Java code, providing there's a class named Dollar defined. But if the variable named object is not of class Dollar it might throw a ClassCastException.