From: deivid via ruby-core Date: 2025-01-10T19:48:37+00:00 Subject: [ruby-core:120605] [Ruby master Misc#21025] What's the default encoding of `String.new`? Issue #21025 has been updated by deivid (David Rodr�guez). I created https://github.com/ruby/ruby/pull/12548 for this. ---------------------------------------- Misc #21025: What's the default encoding of `String.new`? https://bugs.ruby-lang.org/issues/21025#change-111433 * Author: deivid (David Rodr�guez) * Status: Open ---------------------------------------- In the documentation (https://docs.ruby-lang.org/en/3.4/encodings_rdoc.html#label-String+Encoding) I see a good explanation of default string encodings: ![](Captura%20de%20pantalla%202025-01-10%20a%20las%2017.53.06.png) However, it does not mention `String.new` without an argument, which is the one case where I see inconsistent behavior. ``` irb(main):001> "".encoding => # irb(main):002> String.new("").encoding => # irb(main):003> String.new(a="").encoding => # irb(main):004> String.new.encoding => # ``` Should this be documented or changed? ---Files-------------------------------- Captura de pantalla 2025-01-10 a las 17.53.06.png (139 KB) -- 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/