'for'에 해당되는 글 1건
- 2009.05.17 [비교] 반복문 - foreach, for~in
- [비교] 반복문 - foreach, for~in
- 日常茶飯事
- 2009. 5. 17. 15:22
Java
for (String s : arr) {
System.out.println("s=" + s);
}
람다?
Javascrpt
var person = {fname:"John", lname:"Doe", age:25};
for(x in person){
txt = txt + ", " + person[x];
}
for (variable in [object | array]) {
statements
}
--
var arr = ["pantarei", "siliuse", "mir"];
for(var i = 0 ; i < arr.length ; i++){ alert(arr[i]); }
for(var i in arr){ alert(arr[i]); }
Python
languages = ['Java', 'Python', 'C']
for language in languages:
print(language)
}
PHP
foreach($customers as $customer){
echo $customer;
}
Perl
여기도 추가
foreach my $string ( @array ) {
print $string;
}
JSTL
<c:forEach>
Shell
$ for i in 1 2 3
> do
> echo $i
> done
1
2
3
$ for i in 1 2 3; do echo $i; done
1
2
3
$ for n in `find /etc -size 0`; do echo `ls -l $n`; done //xargs를 쓰는게 좋지
awk
Windows Command
> for %a in (1 2 3) do @echo %a
Oracle
Recent comment