documenting-ruby / ruby

A concerted effort to augment and enhance Ruby MRI documentation
http://documenting-ruby.org/
Other
60 stars 118 forks source link

Add Kernel#Array behavior with `nil` to the documentation #113

Open YannIsCoding opened 1 year ago

YannIsCoding commented 1 year ago

Kernel#Array returns an empty array when given nil. However, nil is retained when given an array containing nil. Unfortunately, this somehow surprising behavior is not documented.

Array(nil) # => []
Array([nil]) # => [nil]

Shall I open a PR to remedy this? :)

gazeldx commented 2 weeks ago

Hi @YannIsCoding , [nil].to_a # => [nil]

Screen Shot 2024-10-15 at 10 38 44 AM

It is not surprising to me. The document is clear to me.