"함수 last()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 3개는 보이지 않습니다)
8번째 줄: 8번째 줄:
==JavaScript==
==JavaScript==
[[분류: JavaScript]]
[[분류: JavaScript]]
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var arr = ['apple', 'banana', 'cranberry'];
var arr = ['apple', 'banana', 'cranberry'];
var last = arr[arr.length - 1];
var last = arr[arr.length - 1];
console.log( last ); // cranberry
console.log( last ); // cranberry
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
{{참고|PHP end()}}
{{참고|PHP end()}}
<source lang='php'>
<syntaxhighlight lang='php'>
$fruits = ['apple', 'banana', 'cranberry'];
$fruits = ['apple', 'banana', 'cranberry'];
$last = end($fruits);
$last = end($fruits);
echo $last; // cranberry
echo $last; // cranberry
</source>
</syntaxhighlight>


===Laravel===
===Laravel===
[[category: Laravel]]
[[category: Laravel]]
{{참고|라라벨 last()}}
{{참고|라라벨 last()}}
<source lang='php'>
<syntaxhighlight lang='php'>
$fruits = ['apple', 'banana', 'cranberry'];
$fruits = ['apple', 'banana', 'cranberry'];
$last = last($fruits);
$last = last($fruits);
echo $last; // cranberry
echo $last; // cranberry
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
fruits = ['apple', 'banana', 'cranberry']
fruits = ['apple', 'banana', 'cranberry']
print fruits[-1]
print fruits[-1]
# cranberry
# cranberry
</source>
</syntaxhighlight>
 
==R==
[[분류: R]]
{{참고|R 마지막 원소}}
<syntaxhighlight lang='r'>
x <- c('apple', 'banana', 'cranberry')
tail(x, n=1)
## [1] "cranberry"
</syntaxhighlight>
<syntaxhighlight lang='r'>
x <- c('apple', 'banana', 'cranberry')
x[length(x)]
## [1] "cranberry"
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='Ruby'>
<syntaxhighlight lang='Ruby'>
arr = ['q', 'r', 's', 't']
arr = ['q', 'r', 's', 't']
puts arr.last  
puts arr.last  
# t
# t
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category:Perl]]
[[category:Perl]]
<source lang='perl'>
<syntaxhighlight lang='perl'>
my @arr = ('q', 'r', 's', 't');
my @arr = ('q', 'r', 's', 't');
print $arr[-1] . "\n";
print $arr[-1] . "\n";
# t
# t
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:33 기준 최신판

  다른 뜻에 대해서는 리눅스 last 문서를 참조하십시오.
  다른 뜻에 대해서는 jQuery .last() 문서를 참조하십시오.
  다른 뜻에 대해서는 The End (밴드) 문서를 참조하십시오.
.last()
end()

1 JavaScript[ | ]

var arr = ['apple', 'banana', 'cranberry'];
var last = arr[arr.length - 1];
console.log( last ); // cranberry

2 PHP[ | ]

$fruits = ['apple', 'banana', 'cranberry'];
$last = end($fruits);
echo $last; // cranberry

2.1 Laravel[ | ]

$fruits = ['apple', 'banana', 'cranberry'];
$last = last($fruits);
echo $last; // cranberry

3 Python[ | ]

fruits = ['apple', 'banana', 'cranberry']
print fruits[-1]
# cranberry

4 R[ | ]

x <- c('apple', 'banana', 'cranberry')
tail(x, n=1)
## [1] "cranberry"
x <- c('apple', 'banana', 'cranberry')
x[length(x)]
## [1] "cranberry"

5 Ruby[ | ]

arr = ['q', 'r', 's', 't']
puts arr.last 
# t

6 Perl[ | ]

my @arr = ('q', 'r', 's', 't');
print $arr[-1] . "\n";
# t

7 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}