From: "Eregon (Benoit Daloze) via ruby-dev" Date: 2023-10-06T14:12:50+00:00 Subject: [ruby-dev:52051] [Ruby master Feature#18573] Object#pack1 Issue #18573 has been updated by Eregon (Benoit Daloze). `Array.pack1(obj, format) -> String` sounds weird since there is nothing about Array in there. I think `String.pack1(format, obj)` is the best option. (`String#pack1(obj)` is confusing because of existing `Array#pack(format)` which has the reverse order). (IMO this is something a JIT should optimize but I understand that's hard on CRuby). ---------------------------------------- Feature #18573: Object#pack1 https://bugs.ruby-lang.org/issues/18573#change-104830 * Author: os (Shigeki OHARA) * Status: Open * Priority: Normal ---------------------------------------- # ������ String#unpack1 ��������� Object#pack1 ��������������� # ������ Array#pack ������������������������������������������������������������ Array ��������������� 1 ��������������������������������������������� ``` ruby [codepoint].pack('U') [digest].pack('m0') [mail_body].pack('M') [ip_address].pack('N') ``` ������������������������������������������������������������������������������������������ ��������������������������������������������������������������������������������������� Array ������������������������������������������������������������������������������ # ������ String#unpack ������������ String#unpack1 ������������������������������������������ Array#pack ������������ Object#pack1 ������������������������������������������ ��������������������������������������������������������������������� ``` ruby class Object def pack1(template, option = {}) [self].pack(template, **option) end end ``` # ��������������� * Object ��������������������������������������������������������������������� * ������������������ pack1 ������������������������������������������������������������������������������������������ -- https://bugs.ruby-lang.org/