Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Gophyr19158y@SirDaryl Don't know, haven't really used it. I just ran into someone doing this and his excuse was "I program in Java."
-
f03n1x65038yIt does,
for( int i in array)
{
System.out.println(I);
}
Not so different
Also welcome to devrant! -
f03n1x65038y@masterdoctor lol same I've been using unity when I go home and a tiny bit of java at work
-
binhex4368yThere's a reason why Java devs do that. A list in Python is also iterable. In Java arrays are primitive and do not implement the Iterable interface.
If that was a List<> of any kind a for each clause would work.
In Java 8 the more "functional" way to iterate over a list is something like:
List<String> cars = new ArrayList<>();
// Add some strings
Cars.forEach(car -> foobar(car)); -
@isRantOverflow oh, sweet. Haven't used C++ for a long time, good to know it's evolving.
Related Rants
When you see a Java devotee using Python and they're doing something like this:
array = [1, 2, 3, 4]
for n in range(0,len(array)):
print(array[n])
At least I get to tell them "hey it doesn't have to be so hard just do it like this:"
array = [1, 2, 3, 4]
for n in array:
print(n)
undefined
python