=> 30} def fuga(h) hash end def hoge(&hash) hash end p fuga(h) #=>{1=>10, 2=>20, 3=>30} p hoge(&h) #=>#<Proc:0x0000556990170f08> # やってることは p h.to_proc 変数に格納したHashを&付きで渡してあげると Procオブジェクトが返ってきている 9
O U L N R S T), 2 => %w(D G), 3 => %w(B C M P), 4 => %w(F H V W Y), 5 => %w(K), 8 => %w(J X), 10 => %w(Q Z)} def initialize(chars) letters = chars.to_s.upcase.scan(/\w/) @sum = alfabets.inject(0) {|sum, char| sum + aggregate(char)} end def score @sum end def self.score(chars) self.new(chars).score end private def aggregate(char) SCORE.find {|k, v| v.include?(char)}.first end end 15