Hacker News new | ask | show | jobs
by alexfrydl 1681 days ago
Ruby's “for … in” is syntax sugar in the sense that is just another way to spell an identical piece of code. This would be like if Python let you write “foreach” instead of “for” if you wanted to. Another example in Ruby is how you can say “unless” instead of “if not”.

Python's “for … in” is syntax sugar in the sense that is an abstraction over constantly writing out the iterator protocol.

1 comments

If anything I found Ruby's breadth of syntax sugar a defining characteristic of it - you can express the same program in a million different ways based on the programming paradigm you wish to emulate, or even make a DSL of your own to express the feelings in your heart. Not that I think that's necessarily a good thing though...