Am Donnerstag, 5. September 2013 15:16:59 UTC+2 schrieb jcbollinger: > > > > On Wednesday, September 4, 2013 4:18:01 PM UTC-5, Simon Hönscheid wrote: >> >> Hi List, >> >> I have a hashmap/array construct where i want to lookup data. my current >> lookup looks like that: >> >> foo_uses_a => [ $foo['bar']['a'], $foo['bar2']['a'] ], >> foo_refers_b => [ $foo['bar']['b'], $foo['bar2']['b'] ]; >> >> Is There a way to skip to double reference of $foo and ['a'] or ['b'] per >> line? And make everything a bit nicer? >> It is possible to change the construct to a complete hashmap if that >> helps. >> >> > > There is no language construct that can make the $foo or any of the > indices implicit. You could do something like this, though: > > $foobar = $foo['bar'] > $foobar2 = $foo['bar2'] > > [...] > > foo_uses_a => [$foobar['a'], $foobar2['a']], > foo_refers_b => [$foobar['b'], $foobar2['b']]; > > I don't see much difference there, myself. > > Ultimately, there is no way around the fact that if you use a nested data > structure then you need multiple indices to select data from deep inside. > The only real solution is to structure your data so that you don't need to > select as deeply, but that's not always feasible. > > > John > > Hi John,
Thanks for your thoughts, I think I have to deal with that. Thanks Simon -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
