Ng-repeat="exercise in exercises"


#1

Hello. Why it is used "exercise in exercises" in ng-repeat? Why it isn't "exerciseS in exerciseS"? Term "exercise" isn't used anywhere. It is "exercises" evywhere, because it is "$scope.exercises". Can you explain me please? I am lost in "S"..


#2

It is common to write the iterator variable as a singular object, and the iterable as a pluralized object.

for thing in things

for child in children

for part in parts

for list_item in list

message in messages

exercise in exercises

Making sense, now?


#3

So it is common or it wouldn't work if it would be written "things in things"?


#4

They are one in the same. It's like looking in a milk jug for milk. It will always be found. If we are looking for protein molecules in milk they will be abundant.

for marbles in marbles

All we see is a bag of marbles. Pseudo-code, follows:

for marble in marbles
    if marble.color === bluish:
        favorites.append(marble)

In the above, we are examining the individual marbles, one at a time, that make up the bag of marbles. This is much more practical, and discerning.