ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction
@ 2023-11-28 20:19 stuyam (Stuart Yamartino) via ruby-core
  2023-11-28 20:20 ` [ruby-core:115526] [Ruby master Feature#20027] Add " stuyam (Stuart Yamartino) via ruby-core
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: stuyam (Stuart Yamartino) via ruby-core @ 2023-11-28 20:19 UTC (permalink / raw
  To: ruby-core; +Cc: stuyam (Stuart Yamartino)

Issue #20027 has been reported by stuyam (Stuart Yamartino).

----------------------------------------
Feature #20027: Range Deconstruction
https://bugs.ruby-lang.org/issues/20027

* Author: stuyam (Stuart Yamartino)
* Status: Open
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115526] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
@ 2023-11-28 20:20 ` stuyam (Stuart Yamartino) via ruby-core
  2023-12-06  0:18 ` [ruby-core:115597] " shan (Shannon Skipper) via ruby-core
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stuyam (Stuart Yamartino) via ruby-core @ 2023-11-28 20:20 UTC (permalink / raw
  To: ruby-core; +Cc: stuyam (Stuart Yamartino)

Issue #20027 has been updated by stuyam (Stuart Yamartino).

Subject changed from Range Deconstruction to Add Range Deconstruction

Update title

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105456

* Author: stuyam (Stuart Yamartino)
* Status: Open
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115597] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
  2023-11-28 20:20 ` [ruby-core:115526] [Ruby master Feature#20027] Add " stuyam (Stuart Yamartino) via ruby-core
@ 2023-12-06  0:18 ` shan (Shannon Skipper) via ruby-core
  2023-12-21  2:28 ` [ruby-core:115829] " mame (Yusuke Endoh) via ruby-core
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: shan (Shannon Skipper) via ruby-core @ 2023-12-06  0:18 UTC (permalink / raw
  To: ruby-core; +Cc: shan (Shannon Skipper)

Issue #20027 has been updated by shan (Shannon Skipper).


Pattern matching would be another option though Range doesn't implement #deconstruct or #deconstruct_keys by default.

``` ruby
class Range def deconstruct = [self.begin, self.end] end

42..420 => low, high
```

Just an aside, but you could avoid the performance issues of splatting #to_a by using Range #begin and #end.

```ruby
low, high = (42..420).then { [_1.begin, _1.end] }
```

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105528

* Author: stuyam (Stuart Yamartino)
* Status: Open
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115829] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
  2023-11-28 20:20 ` [ruby-core:115526] [Ruby master Feature#20027] Add " stuyam (Stuart Yamartino) via ruby-core
  2023-12-06  0:18 ` [ruby-core:115597] " shan (Shannon Skipper) via ruby-core
@ 2023-12-21  2:28 ` mame (Yusuke Endoh) via ruby-core
  2023-12-21 20:47 ` [ruby-core:115843] " stuyam (Stuart Yamartino) via ruby-core
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2023-12-21  2:28 UTC (permalink / raw
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #20027 has been updated by mame (Yusuke Endoh).

Status changed from Open to Rejected

We discussed this at the dev meeting and decided to reject it.

Currently, assignment deconstruction is available only for Arrays (note that assignment deconstruction is not pattern matching). Such special handling for Ranges is not justified by the expected frequency of use.

This is my personal opinion, but it might be conceivable to introduce some method that returns `Range#begin` and `#end` as arrays.

```ruby
p (1..100).begin_and_end #=> [1, 100]

start_date, end_date = (Date.yesterday..Date.tomorrow).begin_and_end
```

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105782

* Author: stuyam (Stuart Yamartino)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115843] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
                   ` (2 preceding siblings ...)
  2023-12-21  2:28 ` [ruby-core:115829] " mame (Yusuke Endoh) via ruby-core
@ 2023-12-21 20:47 ` stuyam (Stuart Yamartino) via ruby-core
  2023-12-22  1:12 ` [ruby-core:115844] " Dan0042 (Daniel DeLorme) via ruby-core
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: stuyam (Stuart Yamartino) via ruby-core @ 2023-12-21 20:47 UTC (permalink / raw
  To: ruby-core; +Cc: stuyam (Stuart Yamartino)

Issue #20027 has been updated by stuyam (Stuart Yamartino).


I like your suggestion of the `#begin_and_end` method, that solves the performance issues, it also then relies on solely array deconstruction doing it's own job which is nice! I could see `#begin_and_end` being useful for something like an ORM where you need the endpoints to do a `BETWEEN` in SQL or something and it would allow you to more easily deconstruct a range when a range is being used more as an object to store the endpoints rather than an object to ask questions about things in between the endpoints etc.

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105799

* Author: stuyam (Stuart Yamartino)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115844] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
                   ` (3 preceding siblings ...)
  2023-12-21 20:47 ` [ruby-core:115843] " stuyam (Stuart Yamartino) via ruby-core
@ 2023-12-22  1:12 ` Dan0042 (Daniel DeLorme) via ruby-core
  2023-12-22 15:39 ` [ruby-core:115863] " stuyam (Stuart Yamartino) via ruby-core
  2023-12-22 16:31 ` [ruby-core:115865] " stuyam (Stuart Yamartino) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-core @ 2023-12-22  1:12 UTC (permalink / raw
  To: ruby-core; +Cc: Dan0042 (Daniel DeLorme)

Issue #20027 has been updated by Dan0042 (Daniel DeLorme).


```ruby
(1..42).minmax #=> [1, 42]
(42..1).minmax #=> [nil, nil]
```

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105801

* Author: stuyam (Stuart Yamartino)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115863] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
                   ` (4 preceding siblings ...)
  2023-12-22  1:12 ` [ruby-core:115844] " Dan0042 (Daniel DeLorme) via ruby-core
@ 2023-12-22 15:39 ` stuyam (Stuart Yamartino) via ruby-core
  2023-12-22 16:31 ` [ruby-core:115865] " stuyam (Stuart Yamartino) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: stuyam (Stuart Yamartino) via ruby-core @ 2023-12-22 15:39 UTC (permalink / raw
  To: ruby-core; +Cc: stuyam (Stuart Yamartino)

Issue #20027 has been updated by stuyam (Stuart Yamartino).


Yeah point Dan0042, `#minmax` _almost_ works, but as you point out it does not work because if the range is a reverse range you get `nil` for both values. Interesting!
`
```ruby
(1..42).minmax #=> [1, 42]
(42..1).minmax #=> [nil, nil]

(1..42).then { [_1.begin, _1.end] } #=> [1, 42]
(42..1).then { [_1.begin, _1.end] } #=> [42, 1]
```

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105821

* Author: stuyam (Stuart Yamartino)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:115865] [Ruby master Feature#20027] Add Range Deconstruction
  2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
                   ` (5 preceding siblings ...)
  2023-12-22 15:39 ` [ruby-core:115863] " stuyam (Stuart Yamartino) via ruby-core
@ 2023-12-22 16:31 ` stuyam (Stuart Yamartino) via ruby-core
  6 siblings, 0 replies; 8+ messages in thread
From: stuyam (Stuart Yamartino) via ruby-core @ 2023-12-22 16:31 UTC (permalink / raw
  To: ruby-core; +Cc: stuyam (Stuart Yamartino)

Issue #20027 has been updated by stuyam (Stuart Yamartino).


Conversation moved to new issue for implementation of `#begin_and_end` method on Range: #20080 

----------------------------------------
Feature #20027: Add Range Deconstruction
https://bugs.ruby-lang.org/issues/20027#change-105822

* Author: stuyam (Stuart Yamartino)
* Status: Rejected
* Priority: Normal
----------------------------------------
Ranges are a powerful tool in ruby. A common range I use is a date range such as `(Date.yesterday..Date.tomorrow)`. A range will often be passed around to methods because the dates hold meaning together such as a timeframe for a table filter.
Often I want to grab the original values out of a range like:
```ruby
timeframe = (Date.yesterday..Date.tomorrow)
start_date = timeframe.begin
end_date = timeframe.end

#=> start_date = yesterday
#=> end_date = today
```

Similar to array and hash deconstruction I thought it would be useful to support range deconstruction like this:
```ruby
start_date, end_date = (Date.yesterday..Date.tomorrow)

#=> start_date = yesterday
#=> end_date = today
```


This would also work for endless or beginless ranges since the beginning and end are just nil in those cases:
```ruby
start_date, end_day = ..Date.tomorrow

#=> start_date = nil
#=> end_date = tomorrow
```

You could do this now using `to_a` like:
```ruby
start_date, *middle_dates, end_date = (Date.new(2000,1,1)..Date.new(2023,1,1).to_a
```
However this has unnecessary performance issues by converting the range to an array especially if the range spans a large period, `middle_dates` would hold a very large array. Also if the range resulted in an array with 2 values, `end_date` would be nil and this wouldn't actually work to get the begin and end values.

I think this provides a simple interface for a common pattern of deconstructing ranges into their beginning and end values. It would be useful for ranges regardless of date ranges or other types of ranges since they are essentially tuples. Would love to know what others think about this <3



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-22 16:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 20:19 [ruby-core:115525] [Ruby master Feature#20027] Range Deconstruction stuyam (Stuart Yamartino) via ruby-core
2023-11-28 20:20 ` [ruby-core:115526] [Ruby master Feature#20027] Add " stuyam (Stuart Yamartino) via ruby-core
2023-12-06  0:18 ` [ruby-core:115597] " shan (Shannon Skipper) via ruby-core
2023-12-21  2:28 ` [ruby-core:115829] " mame (Yusuke Endoh) via ruby-core
2023-12-21 20:47 ` [ruby-core:115843] " stuyam (Stuart Yamartino) via ruby-core
2023-12-22  1:12 ` [ruby-core:115844] " Dan0042 (Daniel DeLorme) via ruby-core
2023-12-22 15:39 ` [ruby-core:115863] " stuyam (Stuart Yamartino) via ruby-core
2023-12-22 16:31 ` [ruby-core:115865] " stuyam (Stuart Yamartino) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).