2009å¹´11æ10æ¥23:49 Ruby é層ã®æ·±ãHashãä½æããã¨ãã«ç¥ã£ã¦ãããã便å©ãªã㨠Ruby ã§é層ã®æ·±ãããã·ã¥ï¼ããã·ã¥ã®å¤ãããã«ããã·ã¥ã¨ãï¼ãä½æããã®ã£ã¦é¢åã§ããä½ãé¢åã£ã¦æ¯å宣è¨ããªãã¨ãããªããã§ããã¼ãã¾ãä»ã®è¨èªãã£ã¦ã人ãªãå½ããåãªã®ããããã¾ããããPerl åºèº«ã®åã¨ãã¦ã¯å¤§å¤ã¡ã³ãã¯ãµã¤ããã§ãã ä¾ãã°ãã®ãããªãã¼ã¿æ§é ãèãã¦ã¿ã¾ãã #!/usr/bin/ruby hash = {} hash["hoge"] = 1 p hash # {"hoge"=>1} hash["foo"]["bar"] = 1 p hash # undefined method `[]=' for nil:NilClass (NoMethodError) æåã« hash = {} ã¨å®£è¨ãã¦ããã®ã§ hash["hoge"] = 1 ã®é¨åã¯åé¡ãªã
{{#tags}}- {{label}}
{{/tags}}