vendredi 27 mai 2016

Compress an 'If' Statement

Hoping that this one doesn't cause much trouble in answering, but when writing this out in my Sudoku project, I knew there must be a better way of phrasing this if condition.

Thanks in advance guys.

public static void modVal(int r, int c, int x) {
    if((r>=1 && r<=9) && (c>=1 && c<=9) && (x>=1 && x<=9)) {
        sudoku.set(r,c,x);
    }
}

Aucun commentaire:

Enregistrer un commentaire