home > 比較編 > Perl, PHP, Python, Ruby > functions >

ForNext

Only Do What Only You Can Do

147. multiple return values

VBScript

JScript

Perl

sub first_and_second {
  return ($_[0], $_[1]);
}
@a = (1,2,3);
($x, $y) = first_and_second(@a);

PHP

function first_and_second(&$a) {
  return array($a[0], $a[1]);
}
$a = array(1,2,3);
list($x, $y) =
  first_and_second($a);

Python

def first_and_second(a):
  return a[0], a[1]

x, y = first_and_second([1,2,3])


Ruby

def first_and_second(a)
  return a[0], a[1]
end
x, y = first_and_second([1,2,3])


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