在 Ruby 中更改散列中的每個值 - Changing every value in a hash in Ruby

問題:

I want to change every value in a hash so as to add '%' before and after the value so我想更改散列中的每個值,以便在值前後添加 '%'

{ :a=>'a' , :b=>'b' }

must be changed to必須改爲

{ :a=>'%a%' , :b=>'%b%' }

What's the best way to do this?做到這一點的最佳方法是什麼?


解決方案:

參考一: https://en.stackoom.com/question/Llw9
參考二: https://stackoom.com/question/Llw9
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章