[JAVA] The process of repeatedly extracting an array differs slightly depending on the language ...

You often want to take out arrays one by one with a for statement and assign them to variables. The subtle differences between different languages can damage your brain. Here we will cover Python, JavaScript, and PHP.


With Python


for(Variable in array)
    #Processing you want to repeat

It's in. And Python is indented without {}.

And everyone loves JS

//When in an array
for(Variable of array){
    //Processing you want to repeat
}

It's of. By the way, if it is an object, in is used.

And with PHP

foreach($Array as$variable){
    //Processing you want to repeat
}

Use foreach instead of for statement and as.

It seems to be confused ………

Recommended Posts

The process of repeatedly extracting an array differs slightly depending on the language ...
How the reference of the python array changes depending on the presence or absence of subscripts
An easy way to pad the number with zeros depending on the number of digits [Python]
[Golang] Specify an array in the value of map
Difference in results depending on the argument of multiprocess.Process
Create a shape on the trajectory of an object
Django: Fluctuate the number of child forms depending on the number of input items