Page 1 of 1

[HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Posted: Wed Sep 25, 2024 6:33 am
by raphaelzintec
why no dominance here?

Code: Select all

Object obj = 10;
        final int a = 50;
        switch(obj){
            case Integer d when a==a : {
                System.out.println("Integer "+d);
                break;
            }
            case Double d when a==a : {
                System.out.println("Double "+d);
                break;
            }
            default : System.out.println("Object "+obj);
        }

Re: [HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Posted: Wed Sep 25, 2024 6:56 am
by admin
Note sure which one you think dominates the other here? Integer and Double have no parent/child relation.

Re: [HD-OCP17/21-Fundamentals Pg 299, Sec. 12.5.0 - enhancing-case-labels-with-guards]

Posted: Wed Sep 25, 2024 7:10 am
by raphaelzintec
right sorry i didnt know type must have relation