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
Kellan ScheiberKellan Scheiber 

I have the below class and when I am unable to get my Time [] to assign to by busSchedule variable. I have tried several constructors but am clearly missing something.

public class BusSchedule {
	
    
    
    public Time [] busSchedule;
        
       
    public void putSchedule(string busLine, Time[] schedule){
        Map<String, Time[]> schedule2 = new Map<String, Time[]>();
        schedule2.put(busLine, schedule);
        busSchedule = schedule2.get(busLine);
        }

    public Time[] getSchedule(string busLine){
        Time[] bSched = new Time[]{};
        
            if (busLine !=null) {
            bSched = busSchedule;
        } else {
            bSched.add(Time.newInstance(8,0,0,0));
            bSched.add(Time.newInstance(17,0,0,0));
       }
        
        return bSched;
    }
}

 
Kellan ScheiberKellan Scheiber
I was able to get this corrected I needed to implement a static variable to hold the value across the class.