From: "andrykonchin (Andrew Konchin)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110523] [Ruby master Misc#19087] String#to_c supports "_"
Date: Thu, 27 Oct 2022 16:44:30 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-19087.20221027164430.13553@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19087.20221027164430.13553@ruby-lang.org
Issue #19087 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Misc #19087: String#to_c supports "_"
https://bugs.ruby-lang.org/issues/19087
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
----------------------------------------
I've noticed a minor inconsistent behaviour of `String#to_c` method. It does not treat a sequence of `_` character as an end of meaningful characters:
```ruby
"123".to_c # => (123+0i)
"12_3".to_c # => (123+0i)
"12__3".to_c # => (123+0i)
"12___3".to_c # => (123+0i)
```
Similar methods `#to_i` and `#to_r` treat multiple `_` in a different way - they just ignore characters after it:
```ruby
"12__3".to_i # => 12
"12__3".to_r # => (12/1)
```
I would expect `#to_c` to behave similarly.
---
```
$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
```
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2022-10-27 16:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 16:44 andrykonchin (Andrew Konchin) [this message]
2022-10-28 10:35 ` [ruby-core:110532] [Ruby master Bug#19087] String#to_c supports multiple "_" nobu (Nobuyoshi Nakada)
2022-11-15 15:34 ` [ruby-core:110768] " andrykonchin (Andrew Konchin)
2022-12-09 12:18 ` [ruby-core:111246] " nagachika (Tomoyuki Chikanaga)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-19087.20221027164430.13553@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=ruby-core@neon.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).