ruby--Hash方法汇总(转)
一。给Hash添加默认值 :
- x?=?[1,2]??????????????????#=>?[1,?2]??h?=?{x?=>?2}????????????#=>?{[1,?2]=>2}??h[x]?????????????????????????#=>?2??x[0]?=?5???????????????????#=>?5??h[x]?????????????????????????#=>?nil??h.rehash?????????????????#=>?{[5,?2]=>2}??h[x]?????????????????????????#=>?2?