hash - Ruby and Chef difference in hashes -


i've been programming in ruby little while , have heard using symbols accessing values in hashes "better practice" using strings, e.g.

default[:key] = value    on  default['key'] = value 

i've been working on chef project , noticed chef cookbooks use second way access hash values (via strings). accessing via symbol alternative not work!

so guess question 2 part, should stop using symbols , use string accessors everywhere? , why use of symbols not work?

t.l;d.r. accessing attributes symbol discouraged in favor of strings, despite still in use.

quoting lamont granquist chef in foodcritic (linter) issue here

chef implementation of mashes converts symbols internally strings

the official recommendation in docs use strings.

to complete overview of chef attributes can access them instance method, i.e. node.key.subkey method deprecated , removed in short mid term.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -