[#122643] [Ruby Bug#21498] Windows - Ruby Overrides C Library APIs thus breaking them — "cfis (Charlie Savage) via ruby-core" <ruby-core@...>

Issue #21498 has been reported by cfis (Charlie Savage).

9 messages 2025/07/02

[#122658] [Ruby Feature#21501] Include native filenames in backtraces as sources for native methods — "ivoanjo (Ivo Anjo) via ruby-core" <ruby-core@...>

Issue #21501 has been reported by ivoanjo (Ivo Anjo).

10 messages 2025/07/05

[#122665] [Ruby Bug#21503] \p{Word} does not match on \p{Join_Control} while docs say it does — "procmarco (Marco Concetto Rudilosso) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNTAzIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHByb2NtYXJjbyAoTWFyY28gQ29uY2V0

8 messages 2025/07/07

[#122734] [Ruby Bug#21511] Use-after-free of the execution context after the fiber object carrying it is freed in GC — "tuonigou (tianyang sun) via ruby-core" <ruby-core@...>

Issue #21511 has been reported by tuonigou (tianyang sun).

10 messages 2025/07/14

[#122797] [Ruby Feature#21515] Add `&return` as sugar for `x=my_calculation; return x if x` — "nhorton (Noah Horton) via ruby-core" <ruby-core@...>

Issue #21515 has been reported by nhorton (Noah Horton).

13 messages 2025/07/16

[#122842] [Ruby Feature#21518] Statistical helpers to `Enumerable` — "Amitleshed (Amit Leshed) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNTE4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IEFtaXRsZXNoZWQgKEFtaXQgTGVzaGVk

12 messages 2025/07/23

[#122847] [Ruby Feature#21520] Feature Proposal: Enumerator::Lazy#peek — "nuzair46 (Nuzair Rasheed) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNTIwIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IG51emFpcjQ2IChOdXphaXIgUmFzaGVl

12 messages 2025/07/24

[ruby-core:122675] [Ruby Feature#21455] Add a block argument to Array#join

From: "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date: 2025-07-08 07:52:30 UTC
List: ruby-core #122675
Issue #21455 has been updated by mame (Yusuke Endoh).


I have a different view on this proposal.

If `Array#join` were to accept a block, I would expect its behavior to relate directly to the "join" action itself, not the transformation of each element (which is the responsibility of `map`).

Specifically, it seems most appropriate for the block's return value to be used as the separator between elements. This would allow for dynamic separators based on context, such as the position of the join.

For example, this approach provides an elegant way to handle the Oxford comma:

```ruby
items = ["Apple", "Banana", "Cherry"]

i = 0
str = items.join do
  i += 1
  if i == items.size - 2
    ", and "
  else
    ", "
  end
end

p str #=> "Apple, Banana, and Cherry"
```

I believe this approach is more intuitive and consistent.

To be clear, I am not making a counter-proposal here. My main point is that it feels illogical for `Array#join` to accept a block that performs a `map`-like operation, as that behavior is unrelated to the behavior of "join" itself.

----------------------------------------
Feature #21455: Add a block argument to Array#join
https://bugs.ruby-lang.org/issues/21455#change-113955

* Author: leoarnold (Leo Arnold)
* Status: Open
----------------------------------------
I sometimes come across code like this where
the `Array#join` at the end can easily
be overlooked or stands out like a sore thumb:

```ruby
hex_string = string.bytes.map do |byte|
  format('%02X', byte)
end.join(' ')
```

It seems idiomatic and more succinct
to pass the block to `Array#join` directly:

```ruby
hex_string = string.bytes.join(' ') do |byte|
  format('%02X', byte)
end
```

Pull Request: https://github.com/ruby/ruby/pull/13731



-- 
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/lists/ruby-core.ml.ruby-lang.org/


In This Thread