Skip to content

Fix references to NAN and INFINITY in documentation#973

Merged
byroot merged 1 commit intoruby:masterfrom
themichaelyang:fix-infinity-docs
Apr 18, 2026
Merged

Fix references to NAN and INFINITY in documentation#973
byroot merged 1 commit intoruby:masterfrom
themichaelyang:fix-infinity-docs

Conversation

@themichaelyang
Copy link
Copy Markdown
Contributor

Fixes typos in the documentation for Float::INFINITY and Float::NAN to make the example code work.

This gem redefines Float::NAN as JSON::NaN and Float::INFINITY as JSON::Infinity, so the docs use the wrong casing.

I added both the Float:: and JSON:: variations to make it more clear.

Tested in irb on Ruby 3.4.0:

irb(main):001> JSON.generate([Float::NAN, Float::INFINITY, JSON::NaN, JSON::Infinity, JSON::MinusInfinity], allow_nan: true)
=> "[NaN,Infinity,NaN,Infinity,-Infinity]"

irb(main):002> JSON.generate([Float::Infinity], allow_nan: true)
(irb):2:in '<main>': uninitialized constant Float::Infinity (NameError)

irb(main):003> JSON.generate([Float::NaN], allow_nan: true)
(irb):3:in '<main>': uninitialized constant Float::NaN (NameError)

@byroot byroot merged commit f1e6163 into ruby:master Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants