Feature #11300
closed
[PATCH] Add String#bin for parity with #hex and #oct.
Added by 0x0dea (D.E. Akers) almost 9 years ago.
Updated over 4 years ago.
Description
Proposal¶
It is proposed that String#bin
be added to return the receiver's value when interpreted as a string of binary digits.
Rationale¶
This method's absence is surprising in the presence of #hex
and #oct
.
Files
- Status changed from Open to Feedback
Two points. Unlike #hex
and #oct
, there's little demand for 0/1 strings conversion.
Besides that, String#bin
can be easily confused with "binary (raw) encoding" and cause more surprise.
Any opinion?
Matz.
matz@ruby-lang.org wrote:
Two points. Unlike #hex
and #oct
, there's little demand for 0/1 strings conversion.
Besides that, String#bin
can be easily confused with "binary (raw) encoding" and cause more surprise.
Any opinion?
I agree it is potentially confusing with String#b
and redundant.
I even wish redundant methods like String#hex
and String#oct
can go away,
too; String#to_i
is enough.
- Tracker changed from Bug to Feature
- Backport deleted (
2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN)
Also available in: Atom
PDF
Like0
Like0Like0Like0