4 ms·
As someone who spends most of his time working in Python, the section called One nice thing about Ruby’s scoping made me a little bit jealous. I hate the way P
by sah 19y ago
As someone who spends most of his time working in Python, the section called One nice thing about Ruby’s scoping made me a little bit jealous. I hate the way Python handles default parameters.
Also, I think glyphobet is a little hard on Ruby's range objects. He says:
Python’s xrange() can also be passed around like a variable, but you test for membership with value in myrange instead of ===.
An important difference there is that "value in xrange(10000)" iterates to find the value, while "(1..10000) === value" does something O(1), like 1 <= value < 10000. Range objects are handy, and different from list constructors like range() and generators like xrange(). But I agree that the ".." and "..." syntax is weird.
- glyphobet 19y agoAh... You're right. I thought value in xrange(10000) just checked the endpoints, but it appears to iterate. Someone should write a PEP. :)
- mdemare 19y agoThe syntax may be weird at first, but one gets used to it. More importantly, both inclusive ranges and exclusive ranges are useful. It's convenient to have both. It makes code more readable, compared to having to add a -1 offset.