Jochen Theodorou | 9 May 16:32
Picon

Re: [groovy-user] dif between def obj = new MyObject() vs MyObject obj = new MyObject()

Peter Niederwieser schrieb:
> I think the question was about the difference between "def foo =" and
> "MyObject foo =", not between "def foo =" and "foo =".

my bad...

both declare a local variable (when done in a method or script), only if 
you use MyObject, then Groovy guarantees you that any value assigned to 
foo will be at last of class MyObject at runtime. If this rule is 
violated, then Groovy will throw a runtime exception when the assignment 
is done. Since the root of all classes is Object using Object won't do 
anything special. "def" can be seen as alias for Object atm.

bye blackdrag

--

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane