groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frenchy48 <bam...@in2p3.fr>
Subject Re: changing dynamically the name of classes in a source code
Date Mon, 28 Mar 2016 13:53:22 GMT
Thanks for replying
as a side note OOP appear only in chapter 8 of my book so I have to survive
in the meantime 
A long long time ago I used object logo ... sticking to groovy helps me to
provide the additional codes I want to create simplistic graphics.

now back to the main point:
when I read your example I thought "good Lord I wasn't even aware of that!
how come?"
then I tested .... and 

---------------
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast
object
'scrountch.geom.SFrame[frame1,0,23,300x442,layout=java.awt.BorderLayout,title=,maximized]'
with class 'scrountch.geom.SFrame' to class 'Cadre'
--------------
with 

(SFrame being a groovy class of the framework)

but 

does work ....

so ???? what's the difference?


OC wrote
>> now if you have a factory that returns the proper class and you assign it
>> to
>> a variable typed with a subclass it won't work.
> 
> ===
> 26 /tmp> &lt;w.groovy
> class Localizeděščřžýáíí extends LinkedList { }
> class Factory { static LinkedList list() { return new LinkedList() } }
> 
> Localizeděščřžýáíí ěěě=Factory.list()
> ěěě&lt;&lt;&quot;Actually, it does work, though in Java-based language
> it's a small miracle&quot;
> println &quot;${ěěě.class.simpleName} contains $ěěě&quot;
> 27 /tmp&gt; groovy w 
> Localizeděščřžýáíí contains [Actually, it does work, though in Java-based
> language it's a small miracle]
> 28 /tmp> 
> ===





-----
member of Grumpy Old Programmers
--
View this message in context: http://groovy.329449.n5.nabble.com/changing-dynamically-the-name-of-classes-in-a-source-code-tp5732080p5732085.html
Sent from the Groovy Users mailing list archive at Nabble.com.

Mime
View raw message