3 ms·
I never knew about this zip command. I guess it brings the same utility offered by the TCL foreach loops to python. Still, I wish more languages directly imita
by jostmey 14y ago
I never knew about this zip command. I guess it brings the same utility offered by the TCL foreach loops to python.
Still, I wish more languages directly imitated the TCL foreach loop. I've found that when I code, I wish I could just do some simple task 3-4 times. I am always tempted to create a little function, and to call that function repeatedly. But that seems like overkill. With TCL, I just write a simple loop statement instead of the function. I've found that my code is more compact, and the number of functions that I declare is reduced.
- thomc 14y agoRuby too: ['dog', 'cat', 'bird'].zip(['brown', 'black', 'red']).each {|animal, color| puts "See the #{color} #{animal}?"}