On 2013-24-10 11:19, Erik Dalén wrote:
It is possible in a lot of puppet versions but it is a bug and might get
fixed.

$a = [1,2]
$a[2]=3
notice($a)


It is a bug that is planned to be fixed in Puppet 4. (It cannot be changed in the 3.x series as it would potentially be a breaking change).

Yes, we are serious about semver :-)

The future parser (and hence also in Puppet 4) allows concatenation of array (and merge of hash) to a *new* variable otherwise variables are strictly immutable.

Regards
- henrik

On 22 October 2013 15:20, jcbollinger <john.bollin...@stjude.org
<mailto:john.bollin...@stjude.org>> wrote:



    On Monday, October 21, 2013 1:21:18 PM UTC-5, Sergey Arlashin wrote:

        Hi!
        Is it possible to add a new element to an array inside puppet
        manifest ? Something like ruby's array.push('new_element') ?



    No, it isn't.  It is a fundamental principle of Puppet that
    variables' values cannot be changed once set..

    In particular, the += operator Daniele refers to does not do quite
    what she supposes: it sets the initial value of a local variable by
    appending data to the value of a /separate/ variable of the same
    name at top scope, node scope, or a parent scope
    
(http://docs.puppetlabs.com/puppet/3/reference/lang_variables.html#appending-assignment).
    That may be sufficient for your needs, but it is not what you
    actually asked, and I would not expect the code Daniele presented to
    work.


    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+unsubscr...@googlegroups.com
    <mailto:puppet-users%2bunsubscr...@googlegroups.com>.
    To post to this group, send email to puppet-users@googlegroups.com
    <mailto: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.




--
Erik Dalén

--
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+unsubscr...@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.


--
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+unsubscr...@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.

Reply via email to