Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the signature for Kernel#Float #1435

Conversation

sampersand
Copy link
Contributor

This updates the signature for Kernel#Float.

The way the code checks for Float is pretty interesting:

  • If it's an Integer, Float, or Rational, then it's immediately converted to a float and returned.
  • If it's a String, then it calls rb_str_to_dbl(), passing along whether an exception should occur
  • Otherwise, the .to_f method is called on the argument.

Note that if exception: false is given, the return value may be nil. In addition, when exception: false is supplied, any type can be given for the first argument, but the return value is always nil.

@sampersand sampersand force-pushed the swesterman/23-08-18/update-Kernel#Float branch 2 times, most recently from a61804d to bbf2e7b Compare August 18, 2023 21:26
@sampersand sampersand force-pushed the swesterman/23-08-18/update-Kernel#Float branch from bbf2e7b to 650c9e5 Compare August 18, 2023 21:27
@sampersand
Copy link
Contributor Author

Consolidated in #1445

@sampersand sampersand closed this Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant