DEV Community

Discussion on: Daily Challenge #76 - Bingo! (or not...)

Collapse
 
juyn profile image
Xavier Dubois πŸ‡«πŸ‡· • Edited

PHP Version

/**  
 * Bingo Challenge
 *
 * @param array $input Array of 10 number  
 *
 * @return string  
 */
 function bingo(array $input = []): string  
{  
    // BINGO  
    $winSequence = [2, 9, 14, 7, 15];  

    return ($winSequence === array_intersect($winSequence, $input)) ? 'WIN': 'LOSE';  
}
Collapse
 
aminnairi profile image
Amin

Why adding public before the function keyword?

Collapse
 
juyn profile image
Xavier Dubois πŸ‡«πŸ‡· • Edited

Force of habit.
I never code in a procedural way, I always have a class, so I declare method visibility ...

It's for sure a Fatal Error in a procedural code.

I'll edit my snippet in consequence

Thread Thread
 
aminnairi profile image
Amin

Okay I though it was a new language feature haha.

I didn't found any use case of this function in PHP before but now I do thanks to your take at the challenge. Well done btw!