for..in, foreach
Python
py
for v in items:
print(v)
Swift
swift
for v in items {
print(v)
}
where
で絞れる
swift
for v in items where v != "x" {
print(v)
}
TypeScript
ts
for (const v of items) {
console.log(v);
}
for .. in
は 他の言語と異なり、取れるのが index なので注意
ts
for (const i in items) {
console.log(items[i])
}
Bash
bash
for v in "a" "b" "c" "d" "e"
do
echo $v
done
bash
for i in `seq 1 5`
do
echo $i
done
Ruby
rb
for v in ['a', 'b', 'c', 'd', 'e']
puts v
end
rb
items.each {|v|
puts v
}
PowerShell
powershell
1..10 | ForEach-Object {
echo $_
}
Batch
batch
for /L %i in (1,1,10) do ( echo %i )