diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c index 8477a37a6d..44fb7a4eb7 100644 --- a/ext/socket/basicsocket.c +++ b/ext/socket/basicsocket.c @@ -306,7 +306,7 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock) * ipttl = sock.getsockopt(:IP, :TTL).int * * optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) - * ipttl = optval.unpack("i")[0] + * ipttl = optval.unpack1("i") * * Option values may be structs. Decoding them can be complex as it involves * examining your system headers to determine the correct definition. An diff --git a/io.c b/io.c index e2f6875c3e..0e11b8ad9a 100644 --- a/io.c +++ b/io.c @@ -3324,7 +3324,7 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex) * # each record is prefixed by its 32-bit length * open("variable-record-file") do |f| * while len = f.read(4) - * len = len.unpack("N")[0] # 32-bit length + * len = len.unpack1("N") # 32-bit length * record = f.read(len) # This returns a string even if len is 0. * end * end diff --git a/string.c b/string.c index 7f9559cb83..299d506004 100644 --- a/string.c +++ b/string.c @@ -10831,7 +10831,7 @@ enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr) * * "abc\u3042\x81".scrub #=> "abc\u3042\uFFFD" * "abc\u3042\x81".scrub("*") #=> "abc\u3042*" - * "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" + * "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack1('H*')+'>' } #=> "abc\u3042" */ static VALUE str_scrub(int argc, VALUE *argv, VALUE str) @@ -10853,7 +10853,7 @@ str_scrub(int argc, VALUE *argv, VALUE str) * * "abc\u3042\x81".scrub! #=> "abc\u3042\uFFFD" * "abc\u3042\x81".scrub!("*") #=> "abc\u3042*" - * "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042" + * "abc\u3042\xE3\x80".scrub!{|bytes| '<'+bytes.unpack1('H*')+'>' } #=> "abc\u3042" */ static VALUE str_scrub_bang(int argc, VALUE *argv, VALUE str)