Is there a clean way to index into an array returned by a function? When I try to do it directly, I get a parser error. I have to assign the array to a new variable and index that. # This fails $dc = split($domain,''[.]'')[0] # This works $split_domain = split($domain,''[.]'') $dc = $split_domain[0] I guess it really doesn''t matter, it''s just annoying and breaks my expectations. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/wBDG-Yd9JU8J. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Krzysztof Wilczynski
2012-Aug-03 10:28 UTC
[Puppet Users] Re: How to index into array from a function
Hi, I believe that Puppet''s DSL parser has no concept of such implemented at this point in time. Your expectations are probably set upon looking how this can be done in Ruby, whereas Puppet DSL is not a proper (a full-blown, so to speak) programming language in the sense of what Ruby is, for instance, and its parser etc is limited. I am sorry to hear that you are disappointed, but it is as it is for the time being :) KW On Thursday, 2 August 2012 15:30:48 UTC+1, Despite wrote:> > Is there a clean way to index into an array returned by a function? When > I try to do it directly, I get a parser error. I have to assign the array > to a new variable and index that. > > # This fails > $dc = split($domain,''[.]'')[0] > > # This works > $split_domain = split($domain,''[.]'') > $dc = $split_domain[0] > > I guess it really doesn''t matter, it''s just annoying and breaks my > expectations. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/MPmtu9jtUnsJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2012-Aug-03 16:10 UTC
[Puppet Users] Re: How to index into array from a function
On Thursday, August 2, 2012 9:30:48 AM UTC-5, Despite wrote:> > Is there a clean way to index into an array returned by a function? When > I try to do it directly, I get a parser error. I have to assign the array > to a new variable and index that. > > # This fails > $dc = split($domain,''[.]'')[0] > > # This works > $split_domain = split($domain,''[.]'') > $dc = $split_domain[0] > > I guess it really doesn''t matter, it''s just annoying and breaks my > expectations. >I''ve seen another area recently where the return values of functions cannot be used directly as an ordinary value (they cannot be used as resource titles). I suspect that the parser just doesn''t anticipate those cases, but perhaps there''s something about the grammar or implementation that makes such cases hard. I encourage you to file a feature request. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/2AWbfIYcLMIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.