Changes since the 1.8.7 release

Compatibility issues

language core

* New syntax and semantics
o Block arguments are always local
o New semantics for block arguments
o defined? and local variables
o Parser expects that your source code has only valid byte
sequence in some character encoding. Use magic comments
to tell the parser which encoding you use.
o New semantics for constant definition in instance_eval
or in module_eval.
* Deprecated syntax
o colon (:) instead of "then" in if/unless or case expression.
o retry in a loop or an iterator.

builtin classes and objects

* Kernel and Object
o Kernel#methods and #singleton_methods used to return an
array of strings but now they return an array of symbols.
* Class and Module
o Module#attr works as Module#attr_reader by default.
Optional boolean argument is obsolete.
o Module#instance_methods, #private_instance_methods and
#public_instance_methods used to return an array of
strings but now they return an array of symbols.
o Extra subclassing check when binding UnboundMethods
* Exceptions
o Exceptions are equal to each other if they belong to
the same class and have the same message and backtrace.
o SystemStackError used to be a subclass of StandardError
but not it is a direct subclass of Exception.
o SecurityError: ditto
o Removed Exception#to_str [Ruby2]
* Enumerable and Enumerator
o Enumerable::Enumerator, compatibility alias of Enumerator,
is removed.
o Enumerable#{map,collect} called without a block returns
an enumerator.
o Even more builtin and bundled libraries have been made to
return an enumerator when called without a block.
* Array
o Array#nitems was removed (use count {|i| !i.nil?})
o Array#choice was removed (use sample)
o Array#[m,n] = nil places nil in the array.
* Hash
o Hash#to_s is equivalent to Hash#inspect
o Semantics for Hash#each and Hash#each_pair
o Hash#select returns a hash
o Hash#key is the new name for #index which has been
deprecated.
o Hash preserves order. It enumerates its elements in the
order in which the keys are inserted.
o Most of the changes in Hash apply to hash like interfaces
such as ENV and *DBM.
* IO operations
o Many methods used to act byte-wise but now some of those act
character-wise. You can use alternate byte-wise methods.
o IO#getc
o Non-blocking IO
o Kernel#open takes "t" for newline conversion
o Kernel#open takes encoding specified
o IO automatically converts byte sequence from a character
encodings into another if specified.
o StringIO#readpartial
o IO.try_convert
o IO.binread
o IO.copy_stream
o IO#binmode?
o IO#close_on_exec= and IO#close_on_exec?
o Limit input in IO#gets, IO#readline, IO#readlines,
IO#each_line, IO#lines, IO.foreach, IO.readlines,
StringIO#gets, StringIO#readline, StringIO#each,
StringIO#readlines
o IO#ungetc, StringIO#ungetc
o IO#ungetbyte, StringIO#ungetbyte
o IO#internal_encoding, IO#external_encoding,
IO#set_encoding
o IO.pipe takes encoding option
o Directive %u behaves like %d for negative values in
printf-style formatting.
* File and Dir operations
o #to_path is called as necessary in File.path, File.chmod,
File.lchmod, File.chown, File.lchown, File.utime,
File.unlink, etc..
o File.world_readable?
o File.world_writable?
o Dir.[], Dir.glob
o Dir.exist?
o Dir.exists?
* File::Stat
o File::Stat#world_readable?
o File::Stat#world_writable?
* String
o No longer an Enumerable: use each_line/lines for line
oriented operation
o Encoding-awareness
o Character-wise semantics in many methods instead of
byte-wise.
o String#[]: Indexing a String with an integer returns a
single character String instead of an integer.
o String#[]=: No longer takes an integer as right
side value. Note that "str[i] = ?c" because of
the following change.
o ?c is evaluated to a single character string
instead of an integer.
* Regexp
o Encoding-awareness
o Regexp matches only with strings which is encoded in a
compatible character encoding to the regexp's.
o Regexp#kcode is removed. use Regexp#encoding.
* Symbols: restriction on literal symbols
* Numeric
o Numeric#div always rounds as Integer#div has done.
o Numeric#fdiv: ditto.
* Integer
o Integer(nil) raises TypeError
* Fixnum
o Fixnum#id2name removed
o Fixnum#to_sym removed
* Struct
o Struct#inspect
* Time
o New format in Time#to_s
o Timezone information preserved on Marshal.dump/load
* $SAFE and bound methods
o New trusted/untrusted model in addition to
tainted/untainted model.
* Deprecation
o $= (global flag for case-sensitiveness on string matching)
o Kernel#to_a
o Kernel#getc, #gsub, #sub
o Kernel#callcc and Continuation now become 'continuation'
bundled library.
o Object#type
o Removed Array and Hash #indices, #indexes
o Hash#index
o ENV.index
o Process::Status#to_int
o Numeric#rdiv
o Precision is removed. Don't cry, it will be redesigned
and come back in future version.
o Symbol#to_int and Symbol#to_i
o $KCODE is no longer effective. Use Encoding related
features of each class.
o VERSION and friends