Christopher,

> On 30. 6. 2024, at 22:42, Christopher Smith <chry...@gmail.com> wrote:
> You're comparing `class java.lang.String` and `class java.lang.Class`.
> 
No, I'm not.
> Which rule in the docs leads you to expect this to be truthy?
> 
The very first documented one, namely

Class case values match if the switch value is an instance of the class

Each class is an instance of java.lang.Class (as actually proves the second 
case which checks it explicitly through a closure; since it is there, I thought 
there's no need to elaborate).

Thanks and all the best,
OC

> 
> On Sun, Jun 30, 2024, 13:17 o...@ocs.cz <mailto:o...@ocs.cz> <o...@ocs.cz 
> <mailto:o...@ocs.cz>> wrote:
>> Hi there,
>> 
>> is this the intended behaviour?
>> 
>> ===
>> groovy:000> switch (String) { case Class: println "C"; break; case {it 
>> instanceof Class}: println "CC" }
>> CC
>> ===> null
>> groovy:000> 
>> ===
>> 
>> Based on the switch documented semantic I would presume "C" should be 
>> printed out, not "CC"?
>> 
>> Thanks and all the best,
>> OC
>> 

Reply via email to