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
anil kumar devunoorianil kumar devunoori 

Why Salesforce allowed to call NON VOID method like VOID method?

public class ApexMethodBehaviourTest {
    
    public static Integer staticNum = 0;
    
    public static Integer getNumber1(Integer i1){
        staticNum = i1;
        return i1;
    }
    
    public static Integer getNumber2(Integer i2){
        getNumber1(i2);
        return staticNum;
    }
    
    public Integer getNumber3(Integer i3){
        return i3;
    }
    
    public Integer getNumber4(Integer i4){
        getNumber3(i4);
        return i4;
    }
    
}

In above code, Salesforce allows us to call NON VOID methods getNumber3(i4); and getNumber1(i2); like VOID methods!
There is another post where Raj and myself discussed and found no documentation about this topic online. 
Any thoughts/ideas will be appreciated much.
anil kumar devunoorianil kumar devunoori
Similar post: We can invoke NON VOID method as VOID method. Interesting!
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005gzvQAA