re: Which types of loops are most popular in the programming languages you use? VIEW POST


From the CoffeeScript language reference:

# Eat lunch.
eat = (food) -> "#{food} eaten."
eat food for food in ['toast', 'cheese', 'wine']

# Fine five course dining.
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake']
menu = (i, dish) -> "Menu Item #{i}: #{dish}" 
menu i + 1, dish for dish, i in courses

# Health conscious meal.
foods = ['broccoli', 'spinach', 'chocolate']
eat food for food in foods when food isnt 'chocolate'

Thanks to map/reduce I don't often use loops, but when I do, I prefer them with coffee.


This reminds me of when I wrote a snake game to learn javascript back in 2013. I was very proud of this particular line of code:

code of conduct - report abuse