T
trans. (T. Onoma)
Er...
How do I change the end exclusivity of a pre-existing range?
T.
How do I change the end exclusivity of a pre-existing range?
T.
trans. (T. Onoma) said:How do I change the end exclusivity of a pre-existing range?
trans. (T. Onoma) said:| > How do I change the end exclusivity of a pre-existing range?
|
| In theory this is impossible because Ranges are designed to be immutable
| objects.
|
| For other objects it is possible to change them via .sendinitialize),
| but Ranges have a check for that.
|
| I think the only option would be using evil-ruby, for now.
|
| But why do you need this?
Testing some modifications to Range. One of them is the addition of
exclude_first? Then I wanted to try out this alternate notation:
-(0..9) # exclude end
+(0..9) # exclude first
~(0..9) # exclude both
Using unary operators, since they have no other meaning for ranges anyway.
Er...
How do I change the end exclusivity of a pre-existing range?
On Sunday 10 October 2004 10:34 pm, Florian Gross wrote:
| trans. (T. Onoma) wrote:
| > How do I change the end exclusivity of a pre-existing range?
|
| In theory this is impossible because Ranges are designed to be immutable
| objects.
|
| For other objects it is possible to change them via .sendinitialize),
| but Ranges have a check for that.
|
| I think the only option would be using evil-ruby, for now.
|
| But why do you need this?
Testing some modifications to Range. One of them is the addition of
exclude_first? Then I wanted to try out this alternate notation:
-(0..9) # exclude end
+(0..9) # exclude first
~(0..9) # exclude both
Using unary operators, since they have no other meaning for ranges anyway.
Have a few other interesting changes, as well. It took a while, but it's
beginning to look quite nice --a good bit more flexible then the current
Range class.
T.
P.S. You may also notice why I'm concerned with precedence, too.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.