home > 比較編 > Perl, PHP, Python, Ruby > execution control >

ForNext

Only Do What Only You Can Do

155. if

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

PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system