jeudi 21 janvier 2016

Better way to write if-else block

I have following code (Sample code) which works very well. I just think if there is any other better way we can write following code snippet more accurately with less code.

if(language == "English")
{
    if(Student_id == 0)
    {
        someFunction();
    }
    else
    {
        if(getMarks(Student_id) > 50 || subjectCount > 1 || projectCount > 0)
        {
            someFunction();
        }
    }
}

Also, please note if Student_id is 0, getMarks(Student_id) throws error

Aucun commentaire:

Enregistrer un commentaire