ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:111181] [Ruby master Feature#19177] optional offset for Array#index
@ 2022-12-03 16:50 Dan0042 (Daniel DeLorme)
  2022-12-04  0:26 ` [ruby-core:111193] " Dan0042 (Daniel DeLorme)
  2022-12-05  9:04 ` [ruby-core:111207] " byroot (Jean Boussier)
  0 siblings, 2 replies; 3+ messages in thread
From: Dan0042 (Daniel DeLorme) @ 2022-12-03 16:50 UTC (permalink / raw)
  To: ruby-core

Issue #19177 has been reported by Dan0042 (Daniel DeLorme).

----------------------------------------
Feature #19177: optional offset for Array#index
https://bugs.ruby-lang.org/issues/19177

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
----------------------------------------
String#index allows an optional offset:

```ruby
"the quick brown fox jumps over the lazy dog".index("the")   #=> 0
"the quick brown fox jumps over the lazy dog".index("the",1) #=> 31
```

I was a bit surprised that Array doesn't support this and I feel it would be a very natural addition:

```ruby
%w[the quick brown fox jumps over the lazy dog].index("the")   #=> 0
%w[the quick brown fox jumps over the lazy dog].index("the",1) #=> 6 instead of ArgumentError
```




-- 
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] 3+ messages in thread

* [ruby-core:111193] [Ruby master Feature#19177] optional offset for Array#index
  2022-12-03 16:50 [ruby-core:111181] [Ruby master Feature#19177] optional offset for Array#index Dan0042 (Daniel DeLorme)
@ 2022-12-04  0:26 ` Dan0042 (Daniel DeLorme)
  2022-12-05  9:04 ` [ruby-core:111207] " byroot (Jean Boussier)
  1 sibling, 0 replies; 3+ messages in thread
From: Dan0042 (Daniel DeLorme) @ 2022-12-04  0:26 UTC (permalink / raw)
  To: ruby-core

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


Oops, duplicate of #17056, which has a PR and was accepted but... never merged?

----------------------------------------
Feature #19177: optional offset for Array#index
https://bugs.ruby-lang.org/issues/19177#change-100477

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
----------------------------------------
String#index allows an optional offset:

```ruby
"the quick brown fox jumps over the lazy dog".index("the")   #=> 0
"the quick brown fox jumps over the lazy dog".index("the",1) #=> 31
```

I was a bit surprised that Array doesn't support this and I feel it would be a very natural addition:

```ruby
%w[the quick brown fox jumps over the lazy dog].index("the")   #=> 0
%w[the quick brown fox jumps over the lazy dog].index("the",1) #=> 6 instead of ArgumentError
```




-- 
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] 3+ messages in thread

* [ruby-core:111207] [Ruby master Feature#19177] optional offset for Array#index
  2022-12-03 16:50 [ruby-core:111181] [Ruby master Feature#19177] optional offset for Array#index Dan0042 (Daniel DeLorme)
  2022-12-04  0:26 ` [ruby-core:111193] " Dan0042 (Daniel DeLorme)
@ 2022-12-05  9:04 ` byroot (Jean Boussier)
  1 sibling, 0 replies; 3+ messages in thread
From: byroot (Jean Boussier) @ 2022-12-05  9:04 UTC (permalink / raw)
  To: ruby-core

Issue #19177 has been updated by byroot (Jean Boussier).

Status changed from Open to Closed

Closing as duplicate.

@Dan0042 can you revive the previous issue? The principle was accepted indeed, but it seems there was still a few open questions.

It's probably a bit late for 3.2, but would be worth trying to get this revived in January.

----------------------------------------
Feature #19177: optional offset for Array#index
https://bugs.ruby-lang.org/issues/19177#change-100499

* Author: Dan0042 (Daniel DeLorme)
* Status: Closed
* Priority: Normal
----------------------------------------
String#index allows an optional offset:

```ruby
"the quick brown fox jumps over the lazy dog".index("the")   #=> 0
"the quick brown fox jumps over the lazy dog".index("the",1) #=> 31
```

I was a bit surprised that Array doesn't support this and I feel it would be a very natural addition:

```ruby
%w[the quick brown fox jumps over the lazy dog].index("the")   #=> 0
%w[the quick brown fox jumps over the lazy dog].index("the",1) #=> 6 instead of ArgumentError
```




-- 
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] 3+ messages in thread

end of thread, other threads:[~2022-12-05  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03 16:50 [ruby-core:111181] [Ruby master Feature#19177] optional offset for Array#index Dan0042 (Daniel DeLorme)
2022-12-04  0:26 ` [ruby-core:111193] " Dan0042 (Daniel DeLorme)
2022-12-05  9:04 ` [ruby-core:111207] " byroot (Jean Boussier)

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).