[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:110523] [Ruby master Misc#19087] String#to_c supports "_"
From:       "andrykonchin (Andrew Konchin)" <noreply () ruby-lang ! org>
Date:       2022-10-27 16:44:30
Message-ID: redmine.issue-19087.20221027164430.13553 () ruby-lang ! org
[Download RAW message or body]

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/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic