From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2024-09-05T08:54:16+00:00 Subject: [ruby-core:119062] [Ruby master Feature#20703] Alias StringIO#string to StringIO#to_s/to_str Issue #20703 has been updated by matz (Yukihiro Matsumoto). Since `StringIO` is a IO-like object, not String-like object, so it should not provide `to_str`. And string body of a StringIO tends to be long, so simple alias of `string` to `to_s` does not always work well. So please use `string` method if you want string body from a StringIO. Matz. ---------------------------------------- Feature #20703: Alias StringIO#string to StringIO#to_s/to_str https://bugs.ruby-lang.org/issues/20703#change-109640 * Author: sebyx07 (Sebastian Buza) * Status: Rejected ---------------------------------------- # 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 ```ruby my_sio = StringIO.new('my string') # current puts "value: #{my_sio}" # value: # # after puts "value: #{my_sio}" # value: my string ``` - issue: https://github.com/ruby/stringio/issues/102 - pr: https://github.com/ruby/stringio/pull/103 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/