Project

General

Profile

Actions

Feature #20703

open

Alias StringIO#string to StringIO#to_s/to_str

Added by sebyx07 (Sebastian Buza) 4 days ago. Updated 4 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:118970]

Description

Description

Allow to use StringIO.new('my string').to_s to be the same as StringIO.new('my string').string

IMO nobody really uses the current StringIO#to_s, so I don't think it will break other apps.

  • Also added .to_str

That way you can also do interpolation easily

my_sio = StringIO.new('my string')

# current
puts "value: #{my_sio}" # value: #<StringIO:0x0000764bba88eec0>

# after
puts "value: #{my_sio}" # value: my string
Actions #1

Updated by sebyx07 (Sebastian Buza) 4 days ago

  • Description updated (diff)
Actions #2

Updated by sebyx07 (Sebastian Buza) 4 days ago

  • Description updated (diff)

Updated by Dan0042 (Daniel DeLorme) 4 days ago

+1
Might also consider adding #to_str, as I think it makes sense to consider StringIO to be a kind of string.

Actions #5

Updated by sebyx07 (Sebastian Buza) 4 days ago

  • Subject changed from Alias StringIO#string to StringIO#to_s to Alias StringIO#string to StringIO#to_s/to_str
  • Description updated (diff)
Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0