code 1 的可读性是否好于 code 2? 我感觉是的。 原英文博客
#code 1: function pipeline
require 'transproc/hash'
fn = Transproc(:symbolize_keys) >> Transproc(:rename_keys, user_name: :name)
fn.call({ 'user_name' => 'Jane' })
# => { :name => 'Jane' }
#code 2: OO
hash = { 'user_name' => 'Jane' }
hash.symbolize_keys.tap { |h| h[:name] = h.delete(:user_name) }
# => { :name => 'Jane' }