[#116016] [Ruby master Bug#20150] Memory leak in grapheme clusters — "peterzhu2118 (Peter Zhu) via ruby-core" <ruby-core@...>
Issue #20150 has been reported by peterzhu2118 (Peter Zhu).
7 messages
2024/01/04
[#116382] [Ruby master Feature#20205] Enable `frozen_string_literal` by default — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Issue #20205 has been reported by byroot (Jean Boussier).
77 messages
2024/01/23
[ruby-core:116165] [Ruby master Bug#20064] Inconsistent behavior between array splat *nil and hash splat **nil
From:
"jeremyevans0 (Jeremy Evans) via ruby-core" <ruby-core@...>
Date:
2024-01-11 00:25:04 UTC
List:
ruby-core #116165
Issue #20064 has been updated by jeremyevans0 (Jeremy Evans).
I submitted a pull request to support `**nil`: https://github.com/ruby/ruby/pull/9477
----------------------------------------
Bug #20064: Inconsistent behavior between array splat *nil and hash splat **nil
https://bugs.ruby-lang.org/issues/20064#change-106172
* Author: zeke (Zeke Gabrielse)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
This has been discussed in #8507 and #9291 but both were closed because they lacked a clear use case.
I think the following code should work, showing a clear use case:
```ruby
invitation = if params.key?(:inviter_id)
{ invitation_attributes: params.slice(:inviter_id) }
end
User.create(
email: '[email protected]',
first_name: 'John',
first_name: 'Doe',
**invitation,
)
```
Per the previous discussions, this is because `*` uses explicit conversion to array (`to_a`, not `to_ary`), while `**` uses implicit conversion to hash (`to_hash`, not `to_h`).
I find it confusing that you can splat nil into an array, but not nil into a hash. It would make sense for `**` to use explicit conversion.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/