From: Mark Thomas Date: 2007-07-26T04:40:04+09:00 Subject: Re: how to make a[2][2][3]=4 work? On Jul 20, 1:57 pm, Fsormok Fsormok wrote: > > Sure. Use Perl. > > What's the ruby-way of such things? > > e.g.: > > int[eth0][ip] = "10.0.0.1" > int[eth0][mask] = "255.255.255.0" > int[eth0][cidr] = "24" > int[eth1][ip] = "10.0.1.1" > int[eth1][mask] = "255.255.255.0" > int[eth1][cidr] = "24" > . > . > . > > I like it if I have all these informations handy within one hash. But > even for me as a realy ruby-newby this looks much more like perl than > ruby. > > It would be great to hear your thoughts how this would be done "the ruby > way"... > > clean and elegant :-) In my personal opinion, multilevel hashes aren't clean and elegant in any language. I'd try to make an object out of it: class Interface attr_accessor :name, :ip, :mask, :cidr end i = Interface.new i.name = "eth0" i.ip = "10.0.0.1" i.mask = "255.255.255.0" i.cidr = 24 - Mark.