Re:Ruby 3.4, No More TypeError with **Nil as It Is Treated a...
by pzmarzly on Monday May 13, 2024 @03:02PM
(#40346970)
Interestingly, JavaScript has the opposite problem: {...null} is fine (returns {}), but [...null] is not (TypeError: Spread syntax requires ...iterable not be null or undefined).
[ Parent
| on HN ]
Re:Ruby 3.4, No More TypeError with **Nil as It Is Treated a...
by fwlr on Tuesday May 14, 2024 @01:19AM
(#40351868)
I was quite surprised by this, I was certain it wasn’t true, but I checked and it is!
Re:Ruby 3.4, No More TypeError with **Nil as It Is Treated a...
by kevincox on Tuesday May 14, 2024 @09:09AM
(#40354852)
This tricks me all of the time. Part of me wants for it to work to avoid allocating an empty array object in situations like `[...opts?.foo.map(format)]`. On the other hand I appreciate the stricter type safety.
Re:Ruby 3.4, No More TypeError with **Nil as It Is Treated a...
by psychoslave on Friday May 24, 2024 @03:50AM
(#40463935)
Thanks for making me aware of this. I guess {...something ?? {} } and [...something ?? [] ] are then appropriate to avoid any trouble for now.