ForNext
Only Do What Only You Can Do
155. if
Hyperpolyglot Interpreted Languages: PHP, Perl, Python, Ruby より (2012.05.08)
VBScript
JScript
Perl
if ( 0 == $n ) { print "no hits\n" } elsif ( 1 == $n ) { print "one hit\n" } else { print "$n hits\n" }
PHP
if ( 0 == $n ) { echo "no hits\n"; } elseif ( 1 == $n ) { echo "one hit\n"; } else { echo "$n hits\n"; }
Python
if 0 == n: print('no hits') elif 1 == n: print('one hit') else: print(str(n) + ' hits')
Ruby
if n == 0 puts "no hits" elsif 1 == n puts "one hit" else puts "#{n} hits" end