Ruby 3.0.0 リファレンスマニュアル > NEWS for Ruby 3.0.0

NEWS for Ruby 3.0.0

このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。十分な情報と共に書かれた全ての変更のリストはリンク先を参照してください。

言語仕様の変更


pr = proc{|*a, **kw| [a, kw]}

pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]

pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => [[[1, {:a=>1}]], {}]
def method_missing(meth, ...)
  send(:"do_#{meth}", ...)
end
0 => a
p a #=> 0

{b: 0, c: 1} => {b:}
p b #=> 0
# version 3.0
0 in 1 #=> false

# version 2.7
0 in 1 #=> raise NoMatchingPatternError
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre, String => x, String => y, *post]
  p pre  #=> ["a", 1]
  p x    #=> "b"
  p y    #=> "c"
  p post #=> [2, "d", "e", "f", 3]
end
def square(x) = x * x

Command line options

`--help` option

When the environment variable `RUBY_PAGER` or `PAGER` is present and has a non-empty value, and the standard input and output are tty, the `--help` option shows the help message via the pager designated by the value. [feature#16754]

`--backtrace-limit` option

The `--backtrace-limit` option limits the maximum length of a backtrace. [feature#8661]

Core classes updates

Outstanding ones only.


dirty_data = ['--', 'data1', '--', 'data2', '--', 'data3']
dirty_data[(1..).step(2)] # take each second element
# => ["data1", "data2", "data3"]

class ;C end
module ;M1 end
module ;M2 end
C.include M1
M1.include M2
p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]

Stdlib updates

Outstanding ones only.

Compatibility issues

Excluding feature bug fixes.


/foo/.frozen? #=> true
(42...).frozen? # => true

Stdlib compatibility issues

C API updates

Implementation improvements

JIT

Static analysis

RBS

TypeProf


# test.rb
def foo(x)
  if x > 10
    x.to_s
  else
    nil
  end
end

foo(42)
$ typeprof test.rb
# Classes
class Object
  def foo : (Integer) -> String?
end

Miscellaneous changes