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

 
(사용자 3명의 중간 판 13개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{다른뜻|HTML del 태그}}
{{다른뜻|HTML del 태그}}
{{다른뜻|리눅스 unset}}
{{다른뜻|PHP unset()}}
[[분류: 다언어]]
[[분류: 다언어]]
[[category: Array]]
[[category: Array]]
5번째 줄: 7번째 줄:
;del
;del
;unset
;unset
;delete
==JavaScript==
[[분류: JavaScript]]
{{참고|JavaScript delete}}
<syntaxhighlight lang='JavaScript'>
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits.b;
console.log( fruits );
// {a: "apple", c: "cranberry"}
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits['b'];
console.log( fruits );
// {a: "apple", c: "cranberry"}
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
var fruits = ['apple','banana','cranberry'];
delete fruits[1];
console.log(fruits);
// ["apple", empty, "cranberry"]
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
var fruits = ['apple','banana','cranberry'];
fruits.splice(1,1);
console.log(fruits);
// ["apple", "cranberry"]
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='PHP'>
{{참고|PHP unset()}}
<syntaxhighlight lang='PHP'>
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
unset($fruits['b']);
unset($fruits['b']);
17번째 줄: 49번째 줄:
//    [c] => cranberry
//    [c] => cranberry
// )
// )
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
{{참고|파이썬 del}}
<syntaxhighlight lang='Python'>
fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
del fruits['b']
del fruits['b']
print fruits
print fruits
# {'a': 'apple', 'c': 'cranberry'}
# {'a': 'apple', 'c': 'cranberry'}
</source>
</syntaxhighlight>
 
==Perl==
[[category: Perl]]
<syntaxhighlight lang='Perl'>
my %fruits = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cranberry' );
delete $fruits{'b'};
 
foreach my $key (keys %fruits) {
my $value = $fruits{$key};
print "$key : $value\n";
}
#c : cranberry
#a : apple
</syntaxhighlight>
 
==R==
[[분류: R]]
{{참고|R rm()}}
<syntaxhighlight lang='r'>
tmp <- 1:4
tmp
#[1] 1 2 3 4
rm(tmp)
tmp
#Error: object 'tmp' not found
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[함수 removeAt()]]
*[[함수 removeAt()]]
*[[함수 remove()]]
*[[new dictionary]]
*[[new dictionary]]
*[[remove]]
*[[remove]]
*[[array_pop]]
*[[array_pop]]
*[[destructor]]
*[[destructor]]

2021년 3월 19일 (금) 11:18 기준 최신판

  다른 뜻에 대해서는 HTML del 태그 문서를 참조하십시오.
  다른 뜻에 대해서는 리눅스 unset 문서를 참조하십시오.
  다른 뜻에 대해서는 PHP unset() 문서를 참조하십시오.
del
unset
delete

1 JavaScript[ | ]

var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits.b;
console.log( fruits );
// {a: "apple", c: "cranberry"}
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits['b'];
console.log( fruits );
// {a: "apple", c: "cranberry"}
var fruits = ['apple','banana','cranberry'];
delete fruits[1];
console.log(fruits);
// ["apple", empty, "cranberry"]
var fruits = ['apple','banana','cranberry'];
fruits.splice(1,1);
console.log(fruits);
// ["apple", "cranberry"]

2 PHP[ | ]

$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
unset($fruits['b']);
print_r($fruits);
// Array
// (
//     [a] => apple
//     [c] => cranberry
// )

3 Python[ | ]

fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
del fruits['b']
print fruits
# {'a': 'apple', 'c': 'cranberry'}

4 Perl[ | ]

my %fruits = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cranberry' );
delete $fruits{'b'};

foreach my $key (keys %fruits) {
	my $value = $fruits{$key};
	print "$key : $value\n";
}
#c : cranberry
#a : apple

5 R[ | ]

tmp <- 1:4
tmp
#[1] 1 2 3 4
rm(tmp)
tmp
#Error: object 'tmp' not found

6 같이 보기[ | ]

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