function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SUMMIT THAKURSUMMIT THAKUR 

Is there any way to set method return type like list<Class> and return different classes from this method?

class a{
    class b{
        int a;
    }
    class c{
        string b;
    }
    
    static list<class> method(){
        if(condition){
            b obj=new b;
            return obj;
        }
        else{
            c obj=new c;
            return obj;
        }
    }
}

 
Padmanabhan KamuniPadmanabhan Kamuni
Hi Sumit,

There is no way to add Class as List type.

Mark this as answer as best answer if it is solved & keep the community clean.