Project

General

Profile

Actions

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.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:69719]

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

string_bin.patch (2.17 KB) string_bin.patch 0x0dea (D.E. Akers), 06/24/2015 01:00 AM

Updated by matz (Yukihiro Matsumoto) almost 9 years ago

  • 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.

Updated by normalperson (Eric Wong) almost 9 years ago

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.

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0