Ruby 2.3.0 リファレンスマニュアル
> NEWS for Ruby 2.3.0
NEWS for Ruby 2.3.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリストは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。
2.2.0 以降の変更
言語仕様の変更
- frozen-string-literal プラグマ:
- safe navigation operator (ぼっち演算子):
obj.try! {} # valid
obj&. {} # syntax error
- 引数はメソッドが呼び出された場合のみ評価されます。
obj.try!(:foo, bar()) # bar() は常に評価されます
obj&.foo(bar()) # bar() は条件付きで評価されます
obj&.attr += 1
- did_you_mean gem:
- 名前のタイポによって NameError や NoMethodError が起きたときに、自動的に他の似た名前を提案してくれます。
"Yuki".starts_with?("Y")
# => NoMethodError: undefined method `starts_with?' for "Yuki":String
# Did you mean? start_with?
組み込みクラスの更新
- Encoding
- Encoding::IBM037 (alias ebcdic-cp-us; dummy) を追加
組み込みクラスの互換性 (機能追加とバグ修正を除く)
* Array
- Array#select!, Array#keep_if, Array#reject!, and Array#delete_if
no longer changes the receiver array instantly every time the
block is called. [Feature #10714]
- Array#flatten and Array#flatten! no longer try to call #to_ary
method on elements beyond the given level. [Bug #10748]
- Array#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. [Feature #11801]
* Enumerable
- Enumerable#chunk and Enumerable#slice_before no longer takes the
initial_state argument. [Feature #10958]
Use a local variable instead to maintain a state.
* File::Stat
- On Windows File::Stat#ino always returned 0, but now returns
BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low. [Feature #11216]
* Hash
- Hash#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. [Feature #11801]
* IO
- IO#close doesn't raise when the IO object is closed. [Feature #10718]
- IO#each_codepoint raises an exception at incomplete character
before EOF when conversion takes place. [Bug #11444]
* Module
- Module#define_method and Object.define_singleton_method now
require method body, Proc, Method, or a block, and raise
ArgumentError if no block is given directly. [Bug #11283]
* pack/unpack (Array/String)
- j and J directives for pointer width integer type. [Feature #11215]
Stdlib updates (outstanding ones only)
* Logger
- Logger#level= now supports symbol and string levels such as :debug, :info,
:warn, :error, :fatal (case insensitive) [Feature #11695]
- Logger#reopen is added to reopen a log device. [Feature #11696]
* io/wait
- IO#wait_readable no longer checks FIONREAD, it may be used for
non-bytestream IO such as listen sockets.
* Net::FTP
- Net::FTP#mlst is added.
- Net::FTP#mlsd is added.
* nkf
* ObjectSpace (objspace)
- ObjectSpace.count_symbols is added.
- ObjectSpace.count_imemo_objects is added.
- ObjectSpace.internal_class_of is added.
- ObjectSpace.internal_super_of is added.
* OpenSSL
- OpenSSL::SSL::SSLSocket#accept_nonblock and
OpenSSL::SSL::SSLSocket#connect_nonblock supports `exception: false`.
[Feature #10532]
* Pathname
- Pathname#descend and Pathname#ascend supported blockless form.
[Feature #11052]
* Socket
- Socket#connect_nonblock, Socket#accept_nonblock,
TCPServer#accept_nonblock, UNIXServer#accept_nonblock,
BasicSocket#recv_nonblock, BasicSocket#recvmsg_nonblock,
BasicSocket#sendmsg_nonblock all support `exception: false` to return
:wait_readable or :wait_writable symbols instead of raising
IO::WaitReadable or IO::WaitWritable exceptions
[Feature #10532] [Feature #11229]
- BasicSocket#recv and BasicSocket#recv_nonblock allow an output
String buffer argument like IO#read and IO#read_nonblock to reduce
GC overhead [Feature #11242]
* StringIO
- In read-only mode, StringIO#set_encoding no longer sets the encoding
of its buffer string. Setting the encoding of the string directly
without StringIO#set_encoding may cause unpredictable behavior now.
[Bug #11827]
* timeout
- Object#timeout is now warned as deprecated when called.
Stdlib compatibility issues (excluding feature bug fixes)
* ext/coverage/coverage.c
- Coverage.peek_result: new method to allow coverage to be captured without
stopping the coverage tool. [Feature #10816]
* Fiddle
- Fiddle::Function#call releases the GVL. [Feature #11607]
* io-console
- Update to io-console 0.4.5, and change the license to BSD 2-clause
"Simplified" License.
* lib/base64.rb
- Base64.urlsafe_encode64: added a "padding" option to suppress
the padding character ("="). [Feature #10740]
- Base64.urlsafe_decode64: now it accepts not only correctly-padded
input but also unpadded input. [Feature #10740]
* lib/drb/drb.rb
- removed unused argument. https://github.com/ruby/ruby/pull/515
* lib/matrix.rb
- Add Vector#round. https://github.com/ruby/ruby/pull/802
* lib/webrick/utils.rb
- removed unused argument. https://github.com/ruby/ruby/pull/356
* Net::FTP
- Connections are in passive mode per default now. The default mode can
be changed by Net::FTP.default_passive=. [Feature #11612]
* Net::HTTP
- default value of Net::HTTP#open_timeout is now 60 (was nil).
* Net::Telnet
- Net::Telnet is extracted to net-telnet gem. It's unmaintain code.
[Feature #11083]
* Psych
* Rake
- Rake is removed from stdlib. [Feature #11025]
* RDoc
- Updated to RDoc 4.2.1. For full release notes see:
https://github.com/rdoc/rdoc/blob/master/History.rdoc#421--2015-12-22
* RubyGems
- Updated to RubyGems 2.5.1. For full release notes see:
http://docs.seattlerb.org/rubygems/History_txt.html#label-2.5.0+-2F+2015-11-03
and
http://docs.seattlerb.org/rubygems/History_txt.html#label-2.5.1+-2F+2015-12-10
Built-in global variables compatibility issues
* $SAFE
- $SAFE=2 and $SAFE=3 are obsolete. If $SAFE is set to 2 or larger,
an ArgumentError is raised. [Feature #5455]
C API updates
* rb_define_class_id_under() now raises a TypeError exception when the
class is already defined but its superclass does not match the given
superclass, as well as definitions in ruby level.
* rb_timespec_now() is added to fetch current datetime as struct timespec.
[Feature #11558]
* rb_time_timespec_new() is added to create a time object with epoch,
nanosecond, and UTC/localtime/time offset arguments. [Feature #11558]
* rb_autoload() deprecated, use rb_funcall() instead. [Feature #11664]
* rb_compile_error_with_enc(), rb_compile_error(), and rb_compile_bug()
deprecated. these functions are exposed but only for internal use.
external libraries should not use them.
Supported platform changes
* OS/2 is no longer supported
* BeOS is no longer supported
* Borland-C is no longer supported
* Haiku now stable and best effort
Implementation improvements
* Optimize Proc#call to eliminate method frame construction.
[Feature #11569]
* Reconsidering method entry data structure.
[Bug #11278]
* Introducing new table data structure for ID keys tables used by
method table and so on. New table structure is simple and fast
than st_table. [Feature #11420]
* Machine code level tuning for object allocation and method calling
code. r52099, r52254
* RubyVM::InstructionSequence is extended for future improvement.
[Feature #11788]
* Case dispatch is now optimized for all special constant literals
including nil, true, and false. Previously, only literal strings,
symbols, integers and floats compiled to optimized case dispatch.
[Feature #11769]
* Instance variables on non-pure Ruby classes (T_DATA, T_FILE,
etc..) is less expensive to store than before. [Feature #11170]
* All accesses to members of big Struct objects are performed in
constant-time. Previously, Struct elements beyond the first 10
10 elements used a linear scan. [Feature #10585]
* The Set class got several speed up.
[Misc #10754], [r52591]
* Socket and I/O-related improvements
- Calling overhead of most of new keyword-using I/O methods in
[Feature #11229] is reduced by avoiding the inefficient C API
to parse keywords. [Feature #11339]
- The standard library is updated to use the improved
exception-free non-blocking I/O from [Feature #11229].
This has the additional benefit of quieter $DEBUG output in
addition to reducing expensive exceptions. [Feature #11044]
- (Linux-only) waiting on a single FD anywhere in the stdlib no longer
uses select(2), making it immune to slowdowns with high-numbered FDs.
[Feature #11081] [Feature #11377]
* CGI.escapeHTML is optimized with C extension.
https://github.com/ruby/ruby/pull/1164