Ruby 2.4.0 概览

Binding#irb: Start a REPL session like binding.pry

通常大家在调试的时候会选择使用p打印出变量的值或者使用pry,现在,我们又多了一种方法,通过引入binding.irb,可以启动一个类似如pry的REPL
session:

'''
require "irb"

class Test
  def initialize name
      @name = name
  end

  def say
     binding.irb
     puts "hello,#name"
  end
end

Test.new("jack").say

ruby test.rb

#𔓘 Work ruby test.rb

#2.4.0-preview3 :001 > @name
# => "jack"
#2.4.0-preview3 :002 >
'''

Add non-ASCII case conversion to String

字符串增加对非ASCII的操作.

Unify Fixnum and Bignum into Integer

CRuby有两种类型的整数类,分别是Integer和Bignum,现在两者合并,所以在Sequel中,应该使用symbol版本的Bignum.

Float#round with keyword

Float#round现在支持可选的参数,默认的行为是向最近的偶数取整

1
2
3
4
5
6
7
# ruby 2.3
(2.5).round
3

# ruby 2.4
(2.5).round
2