小编Bio*_*ike的帖子

Ruby中的一个内嵌嵌套哈希创建?(我来自Perl)

我是一个Perl人,我已经做了一段时间的哈希:

my %date;

#Assume the scalars are called with 'my' earlier

$date{$month}{$day}{$hours}{$min}{$sec}++

现在我正在学习Ruby,到目前为止我发现使用这个树是做许多键和值的方法.有没有办法使用我用Perl使用一行的简单格式?

 @date = {                                                                                                                                                                      
        month => {                                                                                                                                                                 
          day => {                                                                                                                                                                 
           hours => {                                                                                                                                                              
              min => {                                                                                                                                                             
                sec => 1                                                                                                                                                           
              }                                                                                                                                                                    
            }                                                                                                                                                                      
          }                                                                                                                                                                        
        }                                                                                                                                                                                                                                                                                                                                                     
      }                   

ruby perl hash nested

28
推荐指数
4
解决办法
1万
查看次数

标签 统计

hash ×1

nested ×1

perl ×1

ruby ×1