FAQ
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.


$foo = {
     'bar' => {
       'a' => [
                                 '1',
                                 '2',
                                 '3
                                 '4',
                               ],
       'b' => [
                                 '1',
                                 '2',
                                 '3',
                                 '4',
                                 '5',
                                 '6',
                               ],
     },
     'bar2' => {
       'a' => [
                                 '1',
                                 '2',
                                 '3
                                 '4',
                               ],
       'b' => [
                                 '1',
                                 '2',
                                 '3',
                                 '4',
                                 '5',
                                 '6',
                               ],
     },
}

Thanks for help
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Sep 5, 2013 at 1:17 pm

    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

    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Simon Hönscheid at Sep 5, 2013 at 1:45 pm

    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 4, '13 at 9:18p
activeSep 5, '13 at 1:45p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Simon Hönscheid: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase