NEWS for Ruby 2.6.0¶ ↑
This document is a list of user visible feature changes made between releases except for bug fixes.
Note that each entry is kept so brief that no reason behind or reference information is supplied with. For a full list of changes with all sufficient information, see the ChangeLog file or Redmine (e.g. https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER
)
Changes since the 2.5.0 release¶ ↑
Language changes¶ ↑
-
$SAFE
now is a process global state and can be set to 0 again. [Feature #14250] -
Refinements take place at block passing. [Feature #14223]
-
Refinements take place at Kernel#public_send. [Feature #15326]
-
Refinements take place at Kernel#respond_to?. [Feature #15327]
-
else
withoutrescue
now causes a syntax error. [EXPERIMENTAL] [Feature #14606] -
Constant names may start with a non-ASCII capital letter. [Feature #13770]
-
Endless ranges are introduced. You can use a
Range
that has no end, like(0..)
(or similarly(0...)
). [Feature #12912]The following shows typical use cases:
ary[1..] # identical to ary[1..-1] (1...).each {|index| block } # infinite loop from index 1 ary.zip(1..) {|elem, index| block } # ary.each.with_index(1) { }
-
The “shadowing outer local variable” warning is removed. [Feature #12490]
You can now write the following without warning:
user = users.find {|user| cond(user) }
-
Print
cause
of the exception if the exception is not caught and printed its backtraces and error message. [Feature #8257] -
The flip-flop syntax is deprecated. [Feature #5400]
-
Non-Symbol keys in a keyword arguments hash was prohibited at 2.6.0, but now allowed again. [Bug #15658]
Core classes updates (outstanding ones only)¶ ↑
Array
- New methods
-
Added
Array#union
andArray#difference
instance methods. [Feature #14097]
-
- Modified methods
-
Array#to_h
now accepts a block that maps elements to new key/value pairs. [Feature #15143]
-
- Aliased methods
-
Array#filter
is a new alias forArray#select
. [Feature #13784] -
Array#filter!
is a new alias forArray#select!
. [Feature #13784]
-
Binding
- New methods
-
Added
Binding#source_location
. [Feature #14230]This method returns the source location of the binding, a 2-element array of
__FILE__
and__LINE__
. Traditionally, the same information could be retrieved byeval("[__FILE__, __LINE__]", binding)
, but we are planning to change this behavior so thatKernel#eval
ignores binding's source location [Bug #4352]. So, users should use this newly-introduced method instead ofKernel#eval
.
-
Dir
- New methods
-
Added
Dir#each_child
andDir#children
instance methods. [Feature #13969]
-
Enumerable
- New methods
-
Enumerable#chain
returns an enumerator object that iterates over the elements of the receiver and then those of each argument in sequence. [Feature #15144]
-
- Modified methods
-
Enumerable#to_h
now accepts a block that maps elements to new key/value pairs. [Feature #15143]
-
- Aliased methods
-
Enumerable#filter
is a new alias forEnumerable#select
. [Feature #13784]
-
Enumerator::ArithmeticSequence
-
This is a new class to represent a generator of an arithmetic sequence, that is a number sequence defined by a common difference. It can be used for representing what is similar to Python's slice. You can get an instance of this class from
Numeric#step
andRange#step
.
-
Enumerator::Chain
-
This is a new class to represent a chain of enumerables that works as a single enumerator, generated by such methods as
Enumerable#chain
andEnumerator#+
.
-
Enumerator::Lazy
- Aliased methods
-
Enumerator::Lazy#filter
is a new alias forEnumerator::Lazy#select
. [Feature #13784]
-
Enumerator
- New methods
-
Enumerator#+
returns an enumerator object that iterates over the elements of the receiver and then those of the other operand. [Feature #15144]
-
ENV
- Modified methods
-
ENV.to_h
now accepts a block that maps names and values to new keys and values. [Feature #15143]
-
Exception
- New options
-
Exception#full_message
takes:highlight
and:order
options. [Bug #14324]
-
Hash
- Modified methods
-
Hash#merge
,Hash#merge!
, andHash#update
now accept multiple arguments. [Feature #15111] -
Hash#to_h
now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
- Aliased methods
-
Hash#filter
is a new alias forHash#select
. [Feature #13784] -
Hash#filter!
is a new alias forHash#select!
. [Feature #13784]
-
IO
- New options
-
Added new mode character
'x'
to open files for exclusive access. [Feature #11258]
-
Kernel
- Aliased methods
-
Kernel#then is a new alias for Kernel#yield_self. [Feature #14594]
-
- New options
-
Kernel#Complex, Kernel#Float, Kernel#Integer, and Kernel#Rational take an
:exception
option to specify the way of error handling. [Feature #12732] -
Kernel#system
takes an:exception
option to raise an exception on failure. [Feature #14386]
-
- Incompatible changes
-
Kernel#system
andKernel#exec
do not close non-standard file descriptors (the default of the:close_others
option is changed tofalse
, but we still set theFD_CLOEXEC
flag on descriptors we create). [Misc #14907]
-
KeyError
- New options
-
KeyError.new
accepts:receiver
and:key
options to set receiver and key in Ruby code. [Feature #14313]
-
Method
Module
- Modified methods
-
Module#method_defined?
,Module#private_method_defined?
, andModule#protected_method_defined?
now accept the second parameter as optional. If it istrue
(the default value), it checks ancestor modules/classes, or checks only the class itself. [Feature #14944]
-
NameError
- New options
-
NameError.new
accepts a:receiver
option to set receiver in Ruby code. [Feature #14313]
-
NilClass
- New methods
-
NilClass#=~ is added for compatibility. [Feature #15231]
-
NoMethodError
- New options
-
NoMethodError.new
accepts a:receiver
option to set receiver in Ruby code. [Feature #14313]
-
Numeric
- Incompatible changes
-
Numeric#step
now returns an instance of theEnumerator::ArithmeticSequence
class rather than one of theEnumerator
class.
-
OpenStruct
- Modified methods
-
OpenStruct#to_h
now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
Proc
Random
- New methods
-
Added
Random.bytes
. [Feature #4938]
-
Range
- New methods
-
Added
Range#%
instance method. [Feature #14697]
-
- Incompatible changes
-
Range#===
now uses the#cover?
instead of the#include?
method. [Feature #14575] -
Range#cover?
now accepts aRange
object. [Feature #14473] -
Range#step
now returns an instance of theEnumerator::ArithmeticSequence
class rather than one of theEnumerator
class.
-
- Regexp/String
-
Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA [Feature #15195]
-
Update Unicode version and Emoji version from 11.0.0 to 12.0.0. [Feature #15321]
-
Update Unicode version from 10.0.0 to 11.0.0. [Feature #14802]
This includes a rewrite of the grapheme cluster (/X/) algorithm and special-casing for Georgian MTAVRULI on
String#downcase
. -
Update Emoji version from 5.0 to 11.0.0 [Feature #14802]
-
RubyVM::AbstractSyntaxTree
- New methods
-
RubyVM::AbstractSyntaxTree.parse
parses a given string and returns AST nodes. [experimental] -
RubyVM::AbstractSyntaxTree.parse_file
parses a given file and returns AST nodes. [experimental] -
RubyVM::AbstractSyntaxTree.of
returns AST nodes of the given proc or method.- experimental
-
RubyVM
- New methods
-
RubyVM.resolve_feature_path identifies the file that will be loaded by “require(feature)”. [experimental] [Feature #15230]
-
String
-
String#crypt
is now deprecated. [Feature #14915]
- New features
-
String#split
yields each substring to the block if given. [Feature #4780]
-
-
Struct
- Modified methods
-
Struct#to_h
now accepts a block that maps keys and values to new keys and values. [Feature #15143]
-
- Aliased method
-
Struct#filter
is a new alias forStruct#select
. [Feature #13784]
-
Time
- New features
-
Time.new
andTime#getlocal
accept a timezone object as well as a UTC offset string.Time#+
,Time#-
, andTime#succ
also preserve the timezone. [Feature #14850]
-
TracePoint
- New features
-
“script_compiled” event is supported. [Feature #15287]
-
- New methods
-
TracePoint#parameters
[Feature #14694] -
TracePoint#instruction_sequence
[Feature #15287] -
TracePoint#eval_script
[Feature #15287]
-
- Modified methods
-
TracePoint#enable
accepts new keywords “target:” and “target_line:”.- Feature #15289
-
Stdlib updates (outstanding ones only)¶ ↑
BigDecimal
-
Update to version 1.4.0. This version includes several compatibility issues, see Compatibility issues section below for details.
- Modified methods
-
BigDecimal() accepts the new keyword “exception:” similar to Float().
- Note for the differences among recent versions
-
You should want to know the differences among recent versions of bigdecimal. Please select the suitable version of bigdecimal according to the following information.
-
1.3.5 has
BigDecimal.new
without “exception:” keyword. You can see the deprecation warning ofBigDecimal.new
when you specify “-w” option. BigDecimal(),BigDecimal.new
, and Object#to_d methods are the same. -
1.4.0 has
BigDecimal.new
with “exception:” keyword. You always see the deprecation warning ofBigDecimal.new
. Object#to_d method is different from BigDecimal() andBigDecimal.new
. -
2.0.0 will be released soon after releasing Ruby 2.6.0. This version will not have the
BigDecimal.new
method.
-
Bundler
-
Add
Bundler
to Standard Library. [Feature #12733] -
Use 1.17.2, the latest stable version.
-
Coverage
-
A oneshot_lines mode is added. [Feature #15022]
This mode checks “whether each line was executed at least once or not”, instead of “how many times each line was executed”. A hook for each line is fired at most once, and after it is fired the hook flag is removed, i.e., it runs with zero overhead.
- New options
-
Add
:oneshot_lines
keyword argument toCoverage.start
. -
Add
:stop
and:clear
keyword arguments toCoverage.result
. Ifclear
is true, it clears the counters to zero. Ifstop
is true, it disables coverage measurement.
-
- New methods
-
Coverage.line_stub, which is a simple helper function that creates the “stub” of line coverage from a given source code.
-
CSV
-
Upgrade to 3.0.2. This includes performance improvements especially for writing. Writing is about 2 times faster. See github.com/ruby/csv/blob/master/NEWS.md.
-
ERB
- New options
-
Add
:trim_mode
and:eoutvar
keyword arguments toERB.new
. Now non-keyword arguments other than the first one are softly deprecated and will be removed when Ruby 2.5 becomes EOL. [Feature #14256] -
erb command's
-S
option is deprecated, and will be removed in the next version.
-
FileUtils
- New methods
-
FileUtils#cp_lr
. [Feature #4189]
-
Matrix
- New methods
Net
- New options
-
Add
:write_timeout
keyword argument toNet::HTTP.new
. [Feature #13396]
-
- New methods
-
Add
Net::HTTP#write_timeout
andNet::HTTP#write_timeout=
. [Feature #13396]
-
- New constant
-
Add
Net::HTTPClientException
to deprecateNet::HTTPServerException
, whose name is misleading. [Bug #14688]
-
Net::IMAP
-
Add Server Name Indication (SNI) support. [Feature #15594]
-
NKF
-
Upgrade to nkf v2.1.5
-
Psych
-
Upgrade to
Psych
3.1.0
-
RDoc
-
Become about 2 times faster.
-
Use SOURCE_DATE_EPOCH to generate files.
-
Fix method line number that slipped off.
-
Enable
--width
,--exclude
, and--line-numbers
that were ignored. -
Add support for blockquote by “>>>” in default markup notation.
-
Add support for “Raises” lines in TomDoc notation.
-
Fix syntax error output.
-
Fix many parsing bugs.
-
REXML
-
Upgrade to
REXML
3.1.9. See github.com/ruby/rexml/blob/master/NEWS.md.
- Improved some XPath implementations
-
concat()
function: Stringify all arguments before concatenating. -
string()
function: Support context node. -
string()
function: Support processing instruction node. -
Support
"*:#{ELEMENT_NAME}"
syntax in XPath 2.0.
-
- Fixed some XPath implementations
-
"//#{ELEMENT_NAME}[#{POSITION}]"
case -
string()
function: Fixfunction(document)
returns nodes that are out of root elements. -
"/ #{ELEMENT_NAME} "
case -
"/ #{ELEMENT_NAME} [ #{PREDICATE} ]"
case -
"/ #{AXIS}::#{ELEMENT_NAME}"
case -
"#{N}-#{M}"
case: One or more white spaces were required before"-"
-
"/child::node()"
case -
"#{FUNCTION}()/#{PATH}"
case -
"@#{ATTRIBUTE}/parent::"
case -
"name(#{NODE_SET})"
case
-
-
CSV
-
Upgrade to 3.0.9. See github.com/ruby/csv/blob/master/NEWS.md.
-
Date
-
Date.jisx0301
,Date#jisx0301
, andDate.parse
provisionally support the new Japanese era as an informal extension, until the new JIS X 0301 is issued. [Feature #15742]
-
RSS
- New options
-
RSS::Parser.parse
now accepts options asHash
.:validate
,:ignore_unknown_element
,:parser_class
options are available.
-
- RubyGems
-
Upgrade to RubyGems 3.0.1
-
Set
- Aliased methods
-
Set#filter!
is a new alias forSet#select!
. [Feature #13784]
-
URI
Compatibility issues (excluding feature bug fixes)¶ ↑
Dir
-
Dir.glob
with'\0'
-separated pattern list will be deprecated, and is now warned. [Feature #14643]
-
File
-
File.read
,File.binread
,File.write
,File.binwrite
,File.foreach
, andFile.readlines
do not invoke external commands even if the path starts with the pipe character'|'
. [Feature #14245]
-
Object
-
Object#=~ is deprecated. [Feature #15231]
-
Stdlib compatibility issues (excluding feature bug fixes)¶ ↑
-
These standard libraries have been promoted to default gems.
-
e2mmap
-
forwardable
-
irb
-
logger
-
matrix
-
mutex_m
-
ostruct
-
prime
-
rexml
-
rss
-
shell
-
sync
-
thwait
-
tracer
-
BigDecimal
-
The following methods are removed.
-
BigDecimal.allocate
-
BigDecimal.ver
-
-
Every
BigDecimal
object is frozen. [Feature #13984] -
BigDecimal() parses the given string similar to Float().
-
String#to_d parses the receiver string similar to
String#to_f
. -
BigDecimal.new
will be removed in version 2.0.
-
Pathname
-
Pathname#read
,Pathname#binread
,Pathname#write
,Pathname#binwrite
,Pathname#each_line
andPathname#readlines
do not invoke external commands even if the path starts with the pipe character'|'
. This follows [Feature #14245].
-
C API updates¶ ↑
Implementation improvements¶ ↑
-
Speedup
Proc#call
because we don't need to care about$SAFE
any more. [Feature #14318]With
lc_fizzbuzz
benchmark which usesProc#call
many times we can measure x1.4 improvements. [Bug #10212] -
Speedup block.call where
block
is passed block parameter. [Feature #14330]Ruby 2.5 improves block passing performance. [Feature #14045]
Additionally, Ruby 2.6 improves the performance of passed block calling.
-
Introduce an initial implementation of a JIT (Just-in-time) compiler. [Feature #14235] [experimental]
-
--jit
command line option is added to enable JIT.--jit-verbose=1
is good for inspection. Seeruby --help
for others. -
To generate machine code, this JIT compiler uses the C compiler used for building the interpreter. Currently GCC, Clang, and Microsoft Visual C++ are supported for it.
-
--disable-mjit-support
option is added to configure. This is added for JIT debugging, but if you get an error on building a header file for JIT, you can use this option to skip building it as a workaround. -
rb_waitpid reimplemented on Unix-like platforms to maintain compatibility with processes created for JIT [Bug #14867]
-
-
VM generator script renewal; makes the generated VM more optimized. [GH-1779]
-
Thread
cache enabled for pthreads platforms (forThread.new
andThread.start
). [Feature #14757] -
timer thread is eliminated for platforms with POSIX timers. [Misc #14937]
-
Transient Heap (theap) is supported. [Bug #14858] [Feature #14989]
theap is a managed heap for short-living memory objects. For example, making a small and short-living
Hash
object is x2 faster. With rdoc benchmark, we measured 6-7% performance improvement. -
Native implementations (arm32, arm64, ppc64le, win32, win64, x86, amd64) of coroutines to improve performance of
Fiber
significantly. [Feature #14739]
Miscellaneous changes¶ ↑
-
On macOS, shared libraries no longer include a full version number of Ruby in their names. This eliminates the burden of each teeny upgrade on the platform that users need to rebuild every extension library.
- Before
-
libruby.2.6.0.dylib
-
libruby.2.6.dylib -> libruby.2.6.0.dylib
-
libruby.dylib -> libruby.2.6.0.dylib
-
- After
-
libruby.2.6.dylib
-
libruby.dylib -> libruby.2.6.dylib
-
-
Extracted misc/*.el files to github.com/ruby/elisp