1.9.0(2)

1.9ではpが返り値として引数を返すらしい.すごい便利じゃないですか.

def test_1_8()
  ret = [1,2,3].map{|x| x * 2}
  p ret
  ret
end

def test_1_9()
  p [1,2,3].map{|x| x * 2}
end

いままではデバッグプリントするのに test_1_8のように書いてたのが,test_1_9で済むってことですよね.


これでいける?

class Object
  def p_1_9(*val)
    send( :p_1_8, *val)
    return *val
  end

  alias_method :p_1_8, :p
  alias_method :p, :p_1_9
end