카타 8급 Drink about

PHP[ | ]

function people_with_age_drink(int $old): string {
  if( $old < 14 ) return "drink toddy";
  if( $old < 18 ) return "drink coke";
  if( $old < 21 ) return "drink beer";
  return "drink whisky";
}
function people_with_age_drink(int $old): string {
  switch (true) {
    case ($old < 14): return "drink toddy";
    case ($old < 18): return "drink coke";
    case ($old < 21): return "drink beer";
    case ($old >= 21): return "drink whisky";
  }
}
function people_with_age_drink(int $n): string {
  return 'drink ' . ($n < 21 ? $n < 18 ? $n < 14 ? 'toddy' : 'coke' : 'beer' : 'whisky');
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}